Search code examples
delphidelphi-6getprocaddress

Getting a DLL class procedure address in Delphi


I have a DLL file from which I need the memory address of a class procedure. I am getting the handle to the DLL file, but when I use GetProcAddress, I can't get the address of the procedure. I have tried the following strings for the process name parameter:

"ProcName"
"ProcClass.ProcName"
"ProcClass::ProcName"
"ProcInterface::ProcName"
"ProcInterface.ProcName"

In none of the cases have I gotten the memory address of the procedure. I am mostly certain that the procedure is public.

What is the string format for doing this? Would it be easier to declare a function pointing to the external procedure and get the address later? Like this:

procedure ProcName(); stdcall; far; external 'Example.DLL';

ProcPointer := @ProcName;

Solution

  • GetProcAddress only gives you the address for exported functions. Your DLL surely doesn't export the methods of a class!

    Use an PE explorer to look for the exported names. For example, use the PE explorer available in GExperts. I've got a "PE Information" menu entry under the GExperts menu.