Do not use C ++ CLI or native DLL.
Directly in. net ProgramNative code.
In the VB era, there have been many good referers who have made a compilation of direct calls in VB.Code.
A general module is specially designed to dynamically generate assembly code.
In fact, this is the execution of inline ASM.
The old method in. Net still works. But today we will not introduce this, but a more diverse way of using function interfaces.
I wrote a post about 06 years ago and dynamically called the native DLL export function in C.
The method introduced today and this public point both use a new feature of. NET 2.0.
Marshal. getdelegateforfunctionpointer
Unlike dynamic API calling, function pointers are not obtained from external DLL, but are dynamically allocated by. net programs.
It is actually executing inline ASM.
Compared with the old methods in the VB era, it has the advantage that function prototypes can be diversified,
The call can be performed using the delegate method. the. NET type in the parameter is automatically converted to the local type by the framework.
Maybe this is rarely used by the average person.
What are the actual uses?
Use it for fun and display it ;)
It can still be used properly in terms of security protection.
For example, from a pure developer perspective, you can apply this to the registration authorization code.
In addition, it can be used in. Net security protection tools. After the encryption tool encrypts the. NET program, it automatically injects these calls into the program.
You can even compile some simple method bodies into native code during encryption.
You do not need to attach a native DLL.