下表列出了在 Win32 API(在 Wtypes.h 中列出)和 C 樣式函數中使用的資料類型。許多非託管庫包含將這些資料類型作為參數傳遞並傳回值的函數。
第三列列出了在Managed 程式碼中使用的相應的 .NET Framework 內建實值型別或類。某些情況下,您可以用大小相同的類型替換此表中列出的類型。
Wtypes.h中的非託管類 非託管 C 語言類型 託管類名 說明
| handle |
void* |
System.IntPtr |
32 位 |
| 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.StringBuilder |
用 ANSI 修飾。 |
| lpcstr |
const char* |
System.String 或 System.StringBuilder |
用 ANSI 修飾。 |
| lpwstr |
wchar_t* |
System.String 或 System.StringBuilder |
用 Unicode 修飾。 |
| lpcwstr |
const wchar_t* |
System.String 或 System.StringBuilder |
用 Unicode 修飾。 |
| float |
float |
System.Single |
32 位 |
| double |
double |
System.Double |
64 位元 |