0
我需要通過它的地址在dll中調用函數。可能嗎?如何通過其地址在dll中調用函數
這是DLL函數:
HMODULE handle
void sethandle(HMODULE a)
{
handle=a;
}
我需要通過它的地址在dll中調用函數。可能嗎?如何通過其地址在dll中調用函數
這是DLL函數:
HMODULE handle
void sethandle(HMODULE a)
{
handle=a;
}
您應該使用GetModuleHandle
和GetProcAddress
功能,下面的代碼:
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)
}
您導出功能? [如果是這樣](http://goffconcepts.com/techarticles/calldll.html),[否則](http://stackoverflow.com/questions/2918234/calling-a-non-exported-function-in-a- dll) – Axalo 2015-04-02 11:48:36
看看'GetProcAddress'文檔 – Predelnik 2015-04-02 11:48:54
看看這裏:[http://stackoverflow.com/questions/18100044/calling-win32-dll-from-c](http://stackoverflow.com/questions/18100044/calling-win32-dll-from-c) – 2015-04-02 11:49:47