高手进来帮忙,急救,C#2.0中是不是不能使用键盘钩子了
如题,发些代码,麻烦大家帮我看看是不是哪里有错:
class keyhook
{
public keyhook()
{
this.statrhook();
}
public event KeyEventHandler KeyUp;
public win32API.API.HookProc keyHook;
public int hkeyhook = 0;
private const int WH_KEYBOARD_LL = 13;
private int WH_KEYBOARD = 2;
public void statrhook()
{
if (this.hkeyhook == 0)
{
this.keyHook = new win32API.API.HookProc(this.KeyboardHookProc);
this.hkeyhook = win32API.API.SetWindowsHookEx(WH_KEYBOARD_LL,
this.keyHook,
Marshal.GetHINSTANCE(
Assembly.GetExecutingAssembly().GetModules()[0]),
0);
MessageBox.Show(this.hkeyhook.ToString(), "钩子 ");
}
//if (this.hkeyhook == 0)
//{
// this.sotphook();
//}
//int errorCode = Marshal.GetLastWin32Error();
//MessageBox.Show(errorCode.ToString(), "钩子 ");