How to RUN a function pointer

H

Harkos

Hello,

I have some code using LoadLibrary, GetProcAddress and FreeLibrary methods
of Win32 API. I can correctly load and dispose any native DLL and even
retrieve the function pointer with GetProcAddress. What I can't is to run
this method. So, does anybody knows how to call this function pointer.

[]'s,
Harkos
 
N

Nicholas Paldino [.NET/C# MVP]

Harkos,

You can not do this in C#, as there is no way to get the method
signature that you need or the metadata to call it. You will have to use
unmanaged code (wrapped in a Managed C++ wrapper) to do this.

Hope this helps.
 
W

Willy Denoyette [MVP]

Harkos wrote:
|| Hello,
||
|| I have some code using LoadLibrary, GetProcAddress and FreeLibrary
|| methods of Win32 API. I can correctly load and dispose any native
|| DLL and even retrieve the function pointer with GetProcAddress. What
|| I can't is to run this method. So, does anybody knows how to call
|| this function pointer.
||
|| []'s,
|| Harkos

You can actually skip the GetProcAddress step. Once you call
LoadLibrary, standard PInvoke calls (see: DllimportAttribute) will use the already-loaded DLL.

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top