Call System.runtime.interopservice, you can use DllImport;
API functions are mainly in "kernel32.dll", "User32.dll", "GDI32.dll",
Kernel32.dll to invoke the LoadLibrary, GetProcAddress, and FreeLibrary below it. Look at MSDN and learn about the prototypes of three functions:
Hmodule LoadLibrary (LPCTSTR lpfilename);
Farproc GetProcAddress (hmodule hmodule, lpcwstr lpprocname);
BOOL FreeLibrary (hmodule hmodule);
LoadLibrary required parameter is the name of the DLL file to be called, and its return value is the handle of this DLL file;
GetProcAddress requires a handle to the DLL that is to be called, this value
Supplied by the return value of LoadLibrary, and the other parameter is the name of the function to invoke in the DLL file. Its return value is a pointer to a function;
The FreeLibrary requires a handle to the function DLL file that is called, and the return value is a Boolean type.
Note: View API functions to use vs Dumpbin.exe
Simply put, IntPtr is the wrapper structure of a struct-type pointer, which is a processing agent for type conversions between different programming languages.
Marshal: Commander of the Air Force, is a remote object management class, there are various operations to choose from.
The string argument is Intptr[dllimport ("user32.dll")]public static extern int MessageBox (int hWnd, IntPtr text, IntPtr caption, uint ty PE); void Main () {//string var str = "hehe"; Create a pointer in the unmanaged heap var ptr = Marshal.stringtohglobalansi (str); Platform invoke MessageBoxA interactive pointer==intptr,uint 1,2,messagebox type; MessageBox (0, PTR, IntPtr.Zero, 2); Clean up marshal.freehglobal (PTR);} Define other methods and classes here
. NET INTPTR ==interoperable pointer