Dynamically P/Invoking a DLL

后端 未结 4 741
夕颜
夕颜 2020-12-18 00:25

What is the best way to dynamically P/Invoke unmanaged code from .NET?

For example, I have a number of unmanaged DLL\'s with common C-style exports between them. I

4条回答
  •  执笔经年
    2020-12-18 01:08

    One option you have is to create a native function which is responsible for loading the appropriate DLL and function into memory and then returning that function to managed code based on your path. This way you can use the GetProcAddress trick naturally and return the function point. You can then PInvoke into this function and get back a Delegate which will then invoke into the proper DLL.

提交回复
热议问题