HINSTANCE g_hDll=NULL;
void CCallerDlg::OnBtnLoad()
{
// TODO: Add your control notification handler code here
g_hDll=LoadLibrary("..\\..\\Debug\\Win32_2.dll");
}
void CCallerDlg::OnBtnUnload()
{
// TODO: Add your control notification handler code here
if(g_hDll)
{
FreeLibrary(g_hDll);
g_hDll=NULL;
}
}
void CCallerDlg::OnBtnGetmodule()
{
// ZwCreateKey = (_ZwCreateKey *) GetProcAddress(GetModuleHandle(L"ntdll.dll"), "ZwCreateKey");
/*
(1) 动态调用:typedef int(*lpAddFun)(int, int); //宏定义函数指针类型
lpAddFun add;//函数指针
HINSTANCE hDll=LoadLibrary(“path”);
add=(lpAddFun)GetProcAddress(hDll, "add");//获得dll中的add函数指针
FreeLibrary(hDll);
*/
HINSTANCE hDll=GetModuleHandle("Win32_2.dll");
char buff[256]="hDll!=g_hDll";
if(hDll==g_hDll )
sprintf(buff,"hDll=g_hDll");
char buff2[256];
sprintf(buff2,"hDll:%d;g_hDll:%d",hDll,g_hDll);
MessageBox(buff2,buff);
}
LoadLibrary;HINSTANCE hDll=GetModuleHandle("Win32_2.dll");
最新推荐文章于 2023-01-09 11:07:58 发布