In addition to performance,. Net also has to pay attention to security issues. We can give. netProgramSet shelling and obfuscation (. NET reactor tool ). In addition to shelling and obfuscation for. net, there is also a way to put important logic and computing in the C ++ class library.
C # The attribute dllimport is used to call the C ++ class library and the Windows API.
1) prepare C ++ DLL first
Extern "C" _ declspec (dllexport) char * getstring () {return "Hello World ";}
Note: select "use MFC in static library" for the project attribute during compilation"
2) Prepare a demo to call the DLL
[Dllimport ("mfcdll. DLL ", entrypoint =" getstring ")] public static extern string getstring (); Private void btncall_click (Object sender, eventargs e) {MessageBox. show (getstring ());}
Note: The compiler must select 32-bit for compiling. If it is called in 64-Bit mode, an exception is thrown.
Display result:
Demo download: http://download.csdn.net/detail/sp951/3760084