C#与C++类型对应表
在使⽤.Net互操作时,经常涉及到⼀些C++到C#的类型转换问题,为了以后⽅便查询,现将⼀些资源整理如下:
C++与C#数据类型对照表
C++数据类型C#数据类型
WORD ushort
DWORD uint
UCHAR int/byte
UCHAR*string/InPtr
unsigned
[MarshalAs(UnmanagedType.LPArray)]byte[]/(IntPtr)
char*
char*string
LPCTSTR string
LPTSTR [MarshalAs(UnmanagedType.LPTStr)] string
long int
ulong uint
Handle IntPtr
HWND IntPtrhtml符号代码对照表
void*IntPtr
int int
int* ref int
*int IntPtr
unsigned int uint
COLORREF uint
Windows(C++)与C#数据类型对照表
Windows数据类型.NET数据类型
BOOL, BOOLEAN Boolean or Int32
BSTR String
BYTE Byte
CHAR Char
DOUBLE Double
DWORD Int32 or UInt32
FLOAT Single
HANDLE (and all other handle
IntPtr, UintPtr or HandleRef
types, such as HFONT and HMENU)
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
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
API与C#数据类型对照表
API数据类型类型描述C#数据类型WORD16位⽆符号整数ushort
LONG32位⽆符号整数int
DWORD32位⽆符号整数uint
HANDLE句柄,32位整数int
UINT32位⽆符号整数uint
BOOL32位布尔型整数bool
LPSTR之乡字符的32位指针string LPCSTR指向常字符的32位指针string
BYTE字节byte
CHAR字符char DWORDLONG64位长度整数long
HDC设备描述表句柄int
HGDIOBJ GDI对象句柄int HINSTANCE实例句柄int
HWM窗⼝句柄int
HPARAM32位消息参数int
LPARAM32位消息参数int
WPARAM32位消息参数int
Wtypes.h与C#数据类型对照表Wtypes.h中的
⾮托管类型
⾮托管C语⾔类型托管类名位数HANDLE void*IntPtr32 BYTE unsigned char Byte8 SHORT short Int1616 WORD unsigned short UInt1616 INT int Int3232 UINT unsigned int UInt3232 LONG long Int3232 BOOL long Int3232 DWORD unsigned long UInt3232 ULONG unsigned long UInt3232 CHAR char Char
LPSTR char*StringStringBuilder⽤ANSI修饰
LPCSTR Const char*StringStringBuilder⽤ANSI修饰
LPWSTR wchar_t*StringStringBuilder⽤ANSI修饰
LPCWSTR Constwchar_t*StringStringBuilder⽤ANSI修饰
FLOAT Float Single32 DOUBLE Double Double64
C++与C#数据类型对照表
C++数据类型C#数据类型
BOOL Int32
BOOLEAN Int32
BYTE UInt16
CHAR UInt16
CHAR UInt16 COLORREF UInt32 DWORD UInt32 DWORD32UInt32 DWORD64UInt64 FLOAT Float HACCEL IntPtr HANDLE IntPtr HBITMAP IntPtr HBRUSH IntPtr HCONV IntPtr HCONVLIST IntPtr HCURSOR IntPtr HDC IntPtr HDDEDATA IntPtr HDESK IntPtr HDROP IntPtr HDWP IntPtr HENHMETAFILE IntPtr HFILE IntPtr HFONT IntPtr HGDIOBJ IntPtr HGLOBAL IntPtr HHOOK IntPtr HICON IntPtr HIMAGELIST IntPtr HIMC IntPtr HINSTANCE IntPtr HKEY IntPtr HLOCAL IntPtr HMENU IntPtr HMETAFILE IntPtr HMODULE IntPtr HMONITOR IntPtr HPALETTE IntPtr HPEN IntPtr HRGN IntPtr HRSRC IntPtr HSZ IntPtr HWINSTA IntPtr HWND IntPtr INT Int32 INT32Int32 INT64Int64 LONG Int32 LONG32Int32 LONG64Int64 LONGLONG Int64 LPARAM IntPtr LPBOOL Int
16[] LPBYTE UInt16[] LPCOLORREF UInt32[] LPCSTR String LPCTSTR String LPCVOID UInt32 LPCWSTR String LPDWORD UInt32 LPHANDLE UInt32 LPINT UInt32 LPLONG UInt32 LPSTR String LPTSTR String LPVOID UInt32 LPWORD UInt32[] LPWSTR String LRESULT IntPtr
LRESULT IntPtr PBOOL Int16[] PBOOLEAN Int16[] PBYTE UInt16[] PCHAR Char[] PCSTR String PCTSTR String PCWCH UInt32 PCWSTR UInt32 PDWORD Int32[] FPFLOAT Float[] PHANDLE UInt32 PHKEY UInt32 PINT Int32[] PLCID UInt32 PLONG Int32[] PLUID Uint32 PSHORT Int16[] PSTR String PTBYTE Char[] PTCHAR Char[] PTSTR String PUCHAR Char[] PUINT UInt32[] PULONG UInt32[] PUSHORT UInt16[] PVOID UInt32 PWCHAR Char[] PWORD Int16[] PWSTR String REGSAM UInt32 SC_HANDLE IntPtr SC_LOCK IntPtr SHORT Int16 SIZE_T UInt32 SSIZE UInt32 TBYTE Char TCHAR Char UCHAR Byte UINT UInt32 UINT32UInt32 UINT64UInt64 ULONG UInt32
ULONG32UInt32 ULONG64UInt64 ULONGLONG UInt64 USHORT UInt16 WORD UInt16 WPARAM IntPtr
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论