1. Use the methods provided by Microsoft's C Runtime Library msvcrt. dll and the functions provided by Win32 API to call the platform.
CodeAs follows:
Class program {// Microsoft's C Runtime Library msvcrt. the puts method provided by DLL [dllimport ("msvcrt. DLL ")] Static extern int puts (string MSG); [dllimport (" msvcrt. DLL ")] Static extern int _ flushall (); // function provided by Win32 API for platform calling [dllimport (" user32.dll ", entrypoint =" MessageBox ")] public static extern int MessageBox (INT hwnd, string lptext, string lpcaption, int wtype); static void main (string [] ARGs) {puts ("Hello world test! "); _ Flushall (); MessageBox (0," Hello world test! "," Title is here ", 0 );}}
2. Use of tools. To view the function information contained in the DLL, you can use the following tools: depends.exe?dumpbin.exe, PE explorer, etc.
The dumpbin format is as follows:
3. Use the entrypoint field to rename the function.
[Dllimport ("nativelib. dll", entrypoint = "printmsg")] public static extern void printmsgrename (string MSG );
Printmsg must be the same as the non-hosted function name. printmsgrename is the renamed function name.