Type correspondence between C/C ++ and C,
Recently, we have been studying functions related to pos printers. Calling winapi and cross-process communication all involve conversions between types.
C/C ++ |
C # |
HANDLE, LPDWORD, LPVOID, void * |
IntPtr |
Maid, LPSTR, LPSTR, char *, const char *, Wchar_t *, LPWSTR |
String [in], StringBuilder [in, out] |
DWORD, unsigned long, Ulong |
UInt32, [financialas (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. hIn |
Unmanaged C language type |
Managed class name |
Description |
HANDLE |
Void * |
System. IntPtr |
32-bit Windows and 64-bit Windows. |
BYTE |
Unsigned char |
System. Byte |
8-digit |
SHORT |
Short |
System. Int16 |
16-bit |
WORD |
Unsigned short |
System. UInt16 |
16-bit |
INT |
Int |
System. Int32 |
32-bit |
UINT |
Unsigned int |
System. UInt32 |
32-bit |
LONG |
Long |
System. Int32 |
32-bit |
BOOL |
Long |
System. Int32 |
32-bit |
DWORD |
Unsigned long |
System. UInt32 |
32-bit |
ULONG |
Unsigned long |
System. UInt32 |
32-bit |
CHAR |
Char |
System. Char |
It is modified with ANSI. |
LPSTR |
Char * |
System. String or System. Text. StringBuilder |
It is modified with ANSI. |
LPCSTR |
Const char * |
System. String or System. Text. StringBuilder |
It is modified with ANSI. |
LPWSTR |
Wchar_t * |
System. String or System. Text. StringBuilder |
Use Unicode. |
LPCWSTR |
Const wchar_t * |
System. String or System. Text. StringBuilder |
Use Unicode. |
FLOAT |
Float |
System. Single |
32-bit |
DOUBLE |
Double |
System. Double |
64-bit |