又要用C#调用C++写好的api函数,为了方便,将网上的数据类型做个整理,方便以后查找,以后遇到需要的在进行查找
C++ | C# | ||
WORD | ushort | ||
DWORD | uint | ||
UCHAR | int/byte(大多数情况下都可以使用int代替,而如果需要严格对齐使用byte) | ||
UCHAR* | string/IntPtr | ||
unsigned char * | [MarshalAs(UnmanagedType.LPArray)]byte[]/?(Intptr) | ||
char* | string | ||
LPCTSTR | string | ||
LPTSTR | [MarshalAs(UnmanagedType.LPTStr)] string | ||
long | int | ||
ulong | uint | ||
Handle | IntPtr | ||
HWND | IntPtr | ||
void * | IntPtr | ||
int | int | ||
int* | ref int | ||
*int | IntPtr | ||
unsigned int | uint | ||
COLORREF | uint |