コード例 #1
0
 /// <summary>
 /// 设置钩子
 /// </summary>
 /// <param name="threadId">传入的进程id</param>
 private void SetHook(uint threadId)
 {
     HookHandle = new HookHandleDelegate(HookCallback);
     HookIntptr = SetWindowsHookEx(HookTypeInt, HookHandle, GetModuleHandle(Process.GetCurrentProcess().MainModule.ModuleName), threadId);
     if (HookIntptr == IntPtr.Zero)
     {
         //hookstop();
         //throw new Exception("hook安装失败");
         ErrorMsg = "hook安装失败";
     }
 }
コード例 #2
0
 private static extern IntPtr SetWindowsHookEx(int idHook, HookHandleDelegate lpfn, IntPtr hmod, uint dwThreadId);