Nader Abbasi

Nader Abbasi

  • NA
  • 55
  • 25.9k

How to load an API method with ordinal number?

Jun 25 2014 12:52 AM
Hi everyone

I have an unmanaged Dll and I want to use it in my app. I have the Dll's methods ordinal numbers. Now I  want to use this methods with their ordinal number.
I have written the following code (I use the kernel32.dll APIs):

// 
LoadLibrary method defined in kernel32.dll. It gets the name of Dll and load it.
IntPtr pDll = LoadLibrary("Foo.dll");

// 
GetProcAddress method defined in kernel 32. It gets the pointer to the dll and name of 

// method to call.
IntPtr pAddressOfFuncToCall = GetProcAddress(pDll, "MyFunc");


Now I need a method like 
GetProcAddress that get the ordinal number of a method instead name.

Can anyone guide me?

Thanks in advanced.