Platform Invoke:提供了一种从托管代码访问并调用非托管代码的方法,应用场景包括从托管代码直接调用Win32 API或其他一些非托管代码实现的库等。
基本类型映射
** C/C++ ** | C# | 备注 |
---|---|---|
HANDLE, LPDWORD, LPVOID, void* | IntPtr | |
LPCTSTR, LPCTSTR, LPSTR, char, const char, Wchar_t*, LPWSTR | String [in], StringBuilder [in, out] | |
DWORD, unsigned long, Ulong | UInt32, [MarshalAs(UnmanagedType.U4)] | |
bool | bool | |
LP |
[In] ref |
|
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 |
结构体映射
winsiggen.exe(P/Invoke Interop Assistant version 1.0)
原文:https://www.cnblogs.com/wesson2019-blog/p/13815682.html