hInst=LoadLibrary("CursorDLL.dll");
if(hInst)
{
SetHookFun=(INHOOK)GetProcAddress(hInst,"SetHook");
UnHookFun=(UNHOOK)GetProcAddress(hInst,"UnHook");
FreeLibrary(hInst);
} SetHookFun(m_hWnd);我运行的时候 出现啦内存不能read的对话框! 于是把FreeLibrary(hInst); 放到OnDestroy中运行 没有报错了 一切正常!我拿出以前写过的一个代码一对比 一样的啊!为什么下面这个没出错! hInst=LoadLibrary("User32.DLL");
if(hInst)
{
fun=(MYFUNC)GetProcAddress(hInst,"SetLayeredWindowAttributes");
FreeLibrary(hInst);//我在别的函数中使用啦fun 运行正常!
}
是什么问题?
后面又调用了 SetHookFun(m_hWnd);
此时函数指针已经不能调用了
而第一种情况, DLL已经从进程中unload了