Reputation:
I am using DllImport
to load a C++ dll. A user uses my code by passing a string
to the MyClass
constructor
I want to load the specified DLL path that was provided in the MyClass
constructor and then I want methods to be able to access the loaded DLL.
How do I code it so that all the user has to type is new MyClass().DoSomething()
?
Upvotes: 0
Views: 1871
Reputation: 10553
You need the LoadLibrary
and GetProcAddress
methods from Win32
and then the Marshal.GetDelegateForFunctionPointer
method. For a detailed description see this msdn blog:
Upvotes: 1