DLL回调EXE里的函数
EXE call Dll里的函數,然后Dll里的函數callback EXE里的函數
?
/*EXE代碼
? 作者:SysProgram
? 日期:2011年3月23日
*/
void Msg(TCHAR *str)
{
?MessageBox(0,str,"Caption",0);
}
void CTestDlgDlg::OnOK()
{
?// TODO: Add extra validation here
?typedef void (*MY_FARPROC)(void (*MY_FARPROC)(TCHAR *str));
?HMODULE hModule = LoadLibrary("C://TestDll//Debug//TestDll.dll");
?MY_FARPROC FunAddress;
?if (hModule == NULL)
?{
??MessageBox("load dll error");
??return;
?}
?FunAddress = (MY_FARPROC)GetProcAddress(hModule,"TestMsg");
?
?FunAddress(Msg);?//將Msg的地址傳入dll
}
?
?
?
?
//---------------------------------------------------------------------------------------------------------------------------
?
?
?
?
/*DLL代碼
? 作者:SysProgram
? 日期:2011年3月23日
*/
?
?
#include <windows.h>
void TestMsg(void (*MY_FARPROC)(TCHAR *str))
{
?MY_FARPROC("hehe");? //回調EXE里的函數
}
BOOL WINAPI DllMain(
?????HINSTANCE hinstDLL,? // handle to the DLL module
?????DWORD fdwReason,???? // reason for calling function
?????LPVOID lpvReserved?? // reserved
)
{
?if (fdwReason == DLL_PROCESS_ATTACH)
?{
?????? //.........................
?}
}
?
//----------------------------------------------------------------------------------------------
//導出函數
EXPORTS
TestMsg
?
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的DLL回调EXE里的函数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 自定义回调函数
- 下一篇: Delphi7的控件安装与删除