【问题标题】:How to call function in dll through its address如何通过地址调用dll中的函数
【发布时间】:2015-04-02 21:57:31
【问题描述】:

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

这是 dll 中的函数:

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

【问题讨论】:

标签: c++ dll


【解决方案1】:

你应该使用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)
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-05-12
    • 2019-03-25
    • 1970-01-01
    • 1970-01-01
    • 2015-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多