#include
HHOOKg_hMouse=NULL;
HHOOKg_hKeyboard=NULL;
#pragmadata_seg("MySec")
HWNDg_hWnd=NULL;
#pragmadata_seg()
//#pragmacomment(linker,"/section:MySec,RWS")
/*HINSTANCEg_hInst;
BOOLWINAPIDllMain(
HINSTANCEhinstDLL,//handletotheDLLmodule
DWORDfdwReason,//reasonforcallingfunction
LPVOIDlpvReserved//reserved
)
{
g_hInst=hinstDLL;
}*/
LRESULTCALLBACKMouseProc(
intnCode,//hookcode
WPARAMwParam,//messageidentifier
LPARAMlParam//mousecoordinates
)
{
return1;
}
LRESULTCALLBACKKeyboardProc(
intcode,//hookcode
WPARAMwParam,//virtual-keycode
LPARAMlParam//keystroke-messageinformation
)
{
if(VK_F2==wParam)
{
SendMessage(g_hWnd,WM_CLOSE,0,0);
UnhookWindowsHookEx(g_hMouse);
UnhookWindowsHookEx(g_hKeyboard);
}
return1;
}
voidSetHook(HWNDhwnd)
{
g_hWnd=hwnd;
g_hMouse=SetWindowsHookEx(WH_MOUSE,MouseProc,GetModuleHandle("Hook"),0);
g_hKeyboard=SetWindowsHookEx(WH_KEYBOARD,KeyboardProc,GetModuleHandle("Hook"),0);
}
|