Platform Invoke Data Types

Platform Invoke Data Types

The following table lists data types used in the Win32 API (listed in Wtypes.h) and C-style functions. Many unmanaged libraries contain functions that pass these data types as parameters and return values. The third column lists the corresponding .NET Framework built-in value type or class that you use in managed code. In some cases, you can substitute a type of the same size for the type listed in the table.

Unmanaged type in Wtypes.h Unmanaged C language typeManaged class nameDescription
HANDLEvoid*System.IntPtr32 bits
BYTEunsigned charSystem.Byte8 bits
SHORTshortSystem.Int1616 bits
WORDunsigned shortSystem.UInt1616 bits
INTintSystem.Int3232 bits
UINTunsigned intSystem.UInt3232 bits
LONGlongSystem.Int3232 bits
BOOLlongSystem.Int3232 bits
DWORDunsigned longSystem.UInt3232 bits
ULONGunsigned longSystem.UInt3232 bits
CHARcharSystem.CharDecorate with ANSI.
LPSTRchar*System.String or System.StringBuilderDecorate with ANSI.
LPCSTRConst char*System.String or System.StringBuilderDecorate with ANSI.
LPWSTRwchar_t*System.String or System.StringBuilderDecorate with Unicode.
LPCWSTRConst wchar_t*System.String or System.StringBuilderDecorate with Unicode.
FLOATFloatSystem.Single32 bits
DOUBLEDoubleSystem.Double64 bits

For corresponding types in Visual Basic .NET, C#, and the Managed Extensions for C++, see the Introduction to the .NET Framework Class Library.

See Also

Marshaling Data with Platform Invoke | Marshaling Strings | Marshaling Classes, Structures, and Unions | Marshaling Arrays of Types | Miscellaneous Marshaling Samples

© 2015 Microsoft