C/C++与C#之间类型的对应
最近在研究pos打印机相关功能, 调用winapi以及跨进程通信等,都涉及到类型之间的转换。
|
C/C++ |
C# |
|
HANDLE, LPDWORD, LPVOID, void* |
IntPtr |
|
LPCTSTR, LPCTSTR, LPSTR, char*, const char*, Wchar_t*, LPWSTR |
String [in], StringBuilder [in, out] |
|
DWORD, unsigned long, Ulong |
UInt32, [MarshalAs(UnmanagedType.U4)] |
|
bool |
bool |
|
LP<struct> |
[In] ref <struct> |
|
SIZE_T |
uint |
|
LPDWORD |
out uint |
|
LPTSTR |
[Out] StringBuilder |
|
PULARGE_INTEGER |
out ulong |
|
WORD |
uInt16 |
|
Byte, unsigned char |
byte |
|
Short |
Int16 |
|
Long, int |
Int32 |
|
float |
single |
|
double |
double |
|
NULL pointer |
IntPtr.Zero |
|
Uint |
Uint32 |
|
Windows Data Type |
.NET Data Type |
|
BOOL, BOOLEAN |
Boolean or Int32 |
|
BSTR |
String |
|
BYTE |
Byte |
|
CHAR |
Char |
|
DOUBLE |
Double |
|
DWORD |
Int32 or UInt32 |
|
FLOAT |
Single |
|
HANDLE (and all other handle types, such as HFONT and HMENU) |
IntPtr, UintPtr or HandleRef |
|
HRESULT |
Int32 or UInt32 |
|
INT |
Int32 |
|
LANGID |
Int16 or UInt16 |
|
LCID |
Int32 or UInt32 |
|
LONG |
Int32 |
|
LPARAM |
IntPtr, UintPtr or Object |
|
LPCSTR |
String |
|
LPCTSTR |
String |
|
LPCWSTR |
String |
|
LPSTR |
String or StringBuilder* |
|
LPTSTR |
String or StringBuilder |
|
LPWSTR |
String or StringBuilder |
|
LPVOID |
IntPtr, UintPtr or Object |
|
LRESULT |
IntPtr |
|
SAFEARRAY |
.NET array type |
|
SHORT |
Int16 |
|
TCHAR |
Char |
|
UCHAR |
SByte |
|
UINT |
Int32 or UInt32 |
|
ULONG |
Int32 or UInt32 |
|
VARIANT |
Object |
|
VARIANT_BOOL |
Boolean |
|
WCHAR |
Char |
|
WORD |
Int16 or UInt16 |
|
WPARAM |
IntPtr, UintPtr or Object |
|
Wtypes.h 中的非托管类型 |
非托管 C 语言类型 |
托管类名 |
说明 |
|
HANDLE |
void* |
System.IntPtr |
在 32 位 Windows 操作系统上为 32 位,在 64 位 Windows 操作系统上为 64 位。 |
|
BYTE |
unsigned char |
System.Byte |
8 位 |
|
SHORT |
short |
System.Int16 |
16 位 |
|
WORD |
unsigned short |
System.UInt16 |
16 位 |
|
INT |
int |
System.Int32 |
32 位 |
|
UINT |
unsigned int |
System.UInt32 |
32 位 |
|
LONG |
long |
System.Int32 |
32 位 |
|
BOOL |
long |
System.Int32 |
32 位 |
|
DWORD |
unsigned long |
System.UInt32 |
32 位 |
|
ULONG |
unsigned long |
System.UInt32 |
32 位 |
|
CHAR |
char |
System.Char |
用 ANSI 修饰。 |
|
LPSTR |
char* |
System.String 或 System.Text.StringBuilder |
用 ANSI 修饰。 |
|
LPCSTR |
Const char* |
System.String 或 System.Text.StringBuilder |
用 ANSI 修饰。 |
|
LPWSTR |
wchar_t* |
System.String 或 System.Text.StringBuilder |
用 Unicode 修饰。 |
|
LPCWSTR |
Const wchar_t* |
System.String 或 System.Text.StringBuilder |
用 Unicode 修饰。 |
|
FLOAT |
Float |
System.Single |
32 位 |
|
DOUBLE |
Double |
System.Double |
64 位 |
C/C++与C#之间类型的对应的更多相关文章
- (转)C#与C++之间类型的对应
C#与C++之间类型的对应 Windows Data Type .NET Data Type BOOL, BOOLEAN Boolean or Int32 BSTR String BYTE Byte ...
- Go语言string,int,int64 ,float之间类型转换方法
(1)int转string ? 1 2 s := strconv.Itoa(i) 等价于s := strconv.FormatInt(int64(i), 10) (2)int64转string ? 1 ...
- C#与C++之间类型的对应
Windows Data Type .NET Data Type BOOL, BOOLEAN Boolean or Int32 BSTR String BYTE Byte CHAR Char DOUB ...
- C#与C++之间类型的对应{转}
Windows Data Type .NET Data Type BOOL, BOOLEAN Boolean or Int32 BSTR String BYTE Byte CHAR ...
- [转]Go语言string,int,int64 ,float之间类型转换方法
1 正文 (1)int转string s := strconv.Itoa(i) 等价于s := strconv.FormatInt(int64(i), 10) (2)int64转string i := ...
- C#与C++之间类型对应关系
//C++中的DLL函数原型为 //extern "C" __declspec(dllexport) bool 方法名一(const char* 变量名1, unsigned c ...
- 【opencv基础】opencv和dlib库中rectangle类型之间的转换
前言 最近使用dlib库的同时也会用到opencv,特别是由于对dlib库的画图函数不熟悉,都想着转换到opencv进行show.本文介绍一下两种开源库中rectangle类型之间的转换. 类型说明 ...
- Oracle中的数据类型和数据类型之间的转换
Oracle中的数据类型 /* ORACLE 中的数据类型: char 长度固定 范围:1-2000 VARCHAR2 长度可变 范围:1-4000 LONG 长度可变 最大的范围2gb 长字符类型 ...
- 浩哥解析MyBatis源码(十)——Type类型模块之类型处理器
原创作品,可以转载,但是请标注出处地址:http://www.cnblogs.com/V1haoge/p/6715063.html 1.回顾 之前的两篇分别解析了类型别名注册器和类型处理器注册器,此二 ...
随机推荐
- webstorm编辑器使用
1.自动生成vue文件模板,如图
- 00004-20180324-20180517-fahrenheit_converter--华氏温度到摄氏温度转换计算器
00004-20180324-20180517-fahrenheit_converter--华氏温度到摄氏温度转换计算器 def fahrenheit_converter(C): fahrenheit ...
- PAT (Advanced Level) Practice 1001 A+B Format (20 分)
题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805528788582400 Calculate a+b and ...
- Java8分组(groupingBy)
1.分组,计数,排序 public class Java8Example1 { public static void main(String[] args) { List<String> ...
- 使用 Nginx 内置 $http_user_agent 来区分( 电脑 pc、手机 mobile、平板 pad )端的内容访问
location / { #pc端内容访问 set $flag "pc"; set $num 1; set $hua "${http_user_agent}"; ...
- COMS3200 The RUSH protocol
Part C (50 marks)The RUSH protocol (Reliable UDP Substitute for HTTP) is a HTTP-like stop-and-wait p ...
- javascript实现继承的三种方式
一.原型链继承 function Parent(){} function Child(){} Child.prototype = new Parent(); 通过对象child的prototype属 ...
- Python3 tkinter基础 TK title 设置窗体的标题
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- 华为Java机试题
1.程序实现目标: 输入一个字符串,将其各个字符对应的ASCII值加5后,输出结果. 程序要求:该字符串只包含小写字母,若其值加5后的字符值大于'z',将其转换成从a开始的字符. package co ...
- centos 7安装phantomjs
centos 7安装phantomjs wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_6 ...