如何通过地址调用dll中的函数

How to call function in dll through its address

我需要通过地址调用dll中的函数。可能吗?

这是dll中的函数:

HMODULE handle
void sethandle(HMODULE a)
{
handle=a;
}

你应该使用GetModuleHandleGetProcAddress函数,代码如下:

LPCWSTR lpszModule = L"kernel32.dll"; // here should be your dll file path name.
HMODULE hModule = GetModuleHandleW(lpszModule);
if (hModule)
{
    typedef void(*fn)(HMODULE);
    fn pF = (fn)GetProcAddress(hModule, "sethandle");
    // use it, like this: pF(a)
}