DLL中的代码:
#define WM_KEY_HOOK WM_USER+200 //自定义消息
extern "C" {
__declspec(dllexport) BOOL APIENTRY StartHook(); //安装键盘钩子
__declspec(dllexport) BOOL APIENTRY EndHook(); //删除键盘钩子
LRESULT WINAPI KeyProc(int nCode,WPARAM wparam,LPARAM lparam);
}
HHOOK hHook=NULL; //鼠标钩子函数句柄
HINSTANCE hInstance=NULL; //DLL实例句柄
#pragma argsused
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
hInstance=hinst;
return 1;
}
//---------------------------------------------------------------------------
__declspec(dllexport) BOOL APIENTRY StartHook()
{
hHook=SetWindowsHookEx(WH_KEYBOARD_LL,(HOOKPROC)KeyProc,hInstance,0);
return (bool)hHook;
}
__declspec(