SetWindowsHookEx(
int idHook, 钩子类型(消息类型)
HOOKPROC lpfn,指针,他指向处理的函数指针
HINSTANCE hMod,实例句柄,Dll句柄
DWORD dwThreadID 被监视线程ID);
具体实现:
void SetHook()
{
DWORD tid =0;
//获取窗口句柄
HWND gameh=FindWindow(NULL,"test.txt-记事本");
if (gameh==0)
{
return;
}
//获取创建这个窗口的线程
tid=GetWindowThreadProcessId(gameh,NULL);
//安装钩子到制定线程 WH_KEYBOARD键盘钩子
g_HookHandle=SetWindowHookEx(WH_KEYBOARD,FunProc,GetModuleHandle("HOOKInject.dll"),tid);
}