不知道错在哪,望高人指点
private void Form1_Load(object sender, EventArgs e){
hWnd = FindWindow(null, "文档.txt - 记事本");
textBox2.Text = hWnd.ToString();
SetHook();
}
public void SetHook()
{
if( _nextHookPtr != IntPtr.Zero ) //已经勾过了
return;
HookProc myhookProc = new HookProc(MyHookProc); //声明一个自己的Hook实现函数的委托对象
//_nextHookPtr = SetWindowsHookEx((int)HookType.Keyboard, myhookProc, IntPtr.Zero, GetCurrentThreadId()); //加到Hook链中
int ID = GetWindowThreadProcessld(hWnd, 0);
_nextHookPtr = SetWindowsHookEx((int)HookType.Keyboard, myhookProc, hWnd, ID);
}
钩子不起作用,请问是怎么回事啊?????