您的位置:首页 > 其它

LoadLibrary;HINSTANCE hDll=GetModuleHandle("Win32_2.dll");

2012-12-24 09:28 399 查看
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);

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: