public bool Install() { if (_installed) { return(false); } // Process if (_process == null) { _process = new RUser32.HWindowsHook(HookProcess); } // Scope if (_scope == EHookScope.Thread) { _nextHookPtr = RUser32.SetWindowsHookEx((int)_type, _process, IntPtr.Zero, RKernel32.GetCurrentThreadId()); } if (_scope == EHookScope.Global) { //IntPtr ptr = Marshal.GetHINSTANCE(Assembly.GetExecutingAssembly().GetModules()[0]); string modulename = global::System.Diagnostics.Process.GetCurrentProcess().MainModule.ModuleName; IntPtr ptr = RKernel32.GetModuleHandle(modulename); _nextHookPtr = RUser32.SetWindowsHookEx((int)_type, _process, ptr, 0); } _installed = true; return(true); }