Conclusion在C#與C/C++作interop時,最重要的就是兩個語言型別的對應,整理如下:
| Unmanage type in Wtypes.h | Unmanaged C type | Managed class name | Managed C# type | Description |
| HANDLE | void * | System.InPtr | N/A | 32 bits on 32-bit windows operation systems, 64 bits on 64-bit windows operation systems. |
| BYTE | unsigned char | System.Byte | byte | 8 bits |
| SHORT | short | System.Int16 | short | 16 bits |
| WORD | unsigned short | System.UInt16 | ushort | 16 bits |
| INT | int | System.Int32 | int | 32 bits |
| UINT | unsigned int | System.UInt32 | uint | 32 bits |
| LONG | long | System.Int32 | int | 32 bits |
| BOOL | long | System.Int32 | int | 32 bits |
| DWORD | unsigned long | System.Int32 | int | 32 bits |
| ULONG | unsigned long | System.Int32 | int | 32 bits |
| CHAR | char | System.Char | char | Decorate with ANSI |
| LPSTR | char * | System.String or System.Text.StringBuilder | string | Decorate with ANSI |
| LPCSTR | const char * | System.String or System.Text.StringBuilder | string | Decorate with ANSI |
| LPWSTR | wchar_t* | System.String or System.Text.StringBuilder | string | Decorate with ANSI |
| LPCWSTR | const wchar_t* | System.String or System.Text.StringBuilder | string | Decorate with ANSI |
| FLOAT | Float | System.Single | float | 32 bits |
| DUOBLE | Double | System.Double | double | 64 bits |
沒有留言:
張貼留言