/// <summary> /// </summary> /// <param name="isSecure"></param> private void doSecuritySetting(bool isSecure) { // 设置开机自动运行 registerRunWhenStart(isSecure, Application.ProductName, Application.StartupPath + @"\井下瓦斯预警录入终端.exe"); // 屏蔽热键和task manager. //new HookHelper().HookStart(); //int rwl = SysHelper.FindWindow("Shell_TrayWnd", null); ////获得任务栏句柄 //SysHelper.ShowWindow(rwl, SW_HIDE); //当nCmdShow=0:隐藏;=1:显示 //// ShowWindow(FindWindow(“Shell_TrayWnd”, null), 1); ////隐藏开始按钮 //int rwl1 = SysHelper.FindWindow("Button", null); //SysHelper.ShowWindow(rwl1, SW_HIDE); Taskbar.Visible = !isSecure; //int desk = FindWindow(“ProgMan”, null); //获得桌面句柄 //ShowWindow(desk, 0); //int desk = FindWindow(“ProgMan”, null); //ShowWindow(desk, 1); //屏蔽Ctrl+Del+Alt proc = HookCallback; using (var curPro = Process.GetCurrentProcess()) using (var curMod = curPro.MainModule) { SetWindowsHookExW(WH_KEYBOARD_LL, proc, GetModuleHandle(curMod.ModuleName), 0); } SysHelper.TaskmgrHide(); }
protected virtual void FreeManaged() { //Not necessesary but whatever... FreeManaged is really only for calling Dispose on members that //are Disposable .NET classes. m_Proc = null; m_MouseSignal = delegate { }; }
public int MouseHook() { HookHandlerDelegate lpfn = new HookHandlerDelegate(HookCaback); hookID_Mouse = SetWindowsHookEx(WH_MOUSE_LL, lpfn, hMod, 0); return(hookID_Mouse); }
/// <summary> /// Sets a hook. /// </summary> public MouseHook() { proc = new HookHandlerDelegate(HookCallback); using (Process currentP = Process.GetCurrentProcess()) using (ProcessModule currentModule = currentP.MainModule) { hookID = WinFunctions.SetWindowsHookEx(14, proc, WinFunctions.GetModuleHandle(currentModule.ModuleName), 0); } }
public KeyboardInterceptor() { Process curProcess = Process.GetCurrentProcess(); ProcessModule curModule = curProcess.MainModule; callbackDelegate = new HookHandlerDelegate(HookCallback); hookID = NativeMethods.SetWindowsHookEx(WH_KEYBOARD_LL, callbackDelegate, NativeMethods.GetModuleHandle(curModule.ModuleName), 0); }
/// <summary> /// Sets up a keyboard hook to trap all keystrokes without passing any to other applications. /// It also disables the win key and allows the print screen key to call the screenshot capturer. /// </summary> public KeyboardHook() { proc = new HookHandlerDelegate(HookCallback); using (Process curProcess = Process.GetCurrentProcess()) using (ProcessModule curModule = curProcess.MainModule) { hookId = NativeMethods.SetWindowsHookEx(keyboardHookId, proc, NativeMethods.GetModuleHandle(curModule.ModuleName), 0); } } // KeyboardHook
public TaskViewController() { handler = new HookHandlerDelegate(HookCallback); using (Process curProcess = Process.GetCurrentProcess()) using (ProcessModule curModule = curProcess.MainModule) { hookId = SetWindowsHookEx(WH_KEYBOARD_LL, handler, GetModuleHandle(curModule.ModuleName), 0); } }
public KeyboardLock() { proc = new HookHandlerDelegate(HookCallback); using (Process curProcess = Process.GetCurrentProcess()) using (ProcessModule curModule = curProcess.MainModule) { hookID = SetWindowsHookEx(WH_KEYBOARD_LL, proc, GetModuleHandle(curModule.ModuleName), 0); } }
public void Release() { if (_hookId != IntPtr.Zero) { NativeMethods.UnhookWindowsHookEx(_hookId); Marshal.Release(_hookId); _hookId = IntPtr.Zero; } _hookHandler = null; }
/// <summary> /// Sets up a keyboard hook to trap all keystrokes without /// passing any to other applications. /// </summary> internal KeyboardHook() { proc = new HookHandlerDelegate(HookCallback); using (Process curProcess = Process.GetCurrentProcess()) using (ProcessModule curModule = curProcess.MainModule) { hookID = NativeMethods.SetWindowsHookEx(WH_KEYBOARD_LL, proc, NativeMethods.GetModuleHandle(curModule.ModuleName), 0); } }
/// <summary> /// Sets up a keyboard hook to trap all keystrokes without /// passing any to other applications. /// </summary> public Keyboard() { proc = HookCallback; using (Process curProcess = Process.GetCurrentProcess()) using (ProcessModule curModule = curProcess.MainModule) { hookID = NativeMethods.SetWindowsHookEx(WH_KEYBOARD_LL, proc, NativeMethods.GetModuleHandle(curModule.ModuleName), 0); } }
/// <summary> /// Sets up a keyboard hook to trap all keystrokes without /// passing any to other applications. /// </summary> public KeyboardHook(AllowKeyDelegate allowKey) { AllowKey = allowKey; using (Process curProcess = Process.GetCurrentProcess()) using (ProcessModule curModule = curProcess.MainModule) { var proc = new HookHandlerDelegate(HookCallback); hookID_ = NativeMethods.SetWindowsHookEx(WH_KEYBOARD_LL, proc, NativeMethods.GetModuleHandle(curModule.ModuleName), 0); } }
public KeyboardListener() { m_Proc = HookCallback; using (Process curProcess = Process.GetCurrentProcess()) { using (ProcessModule curModule = curProcess.MainModule) { m_HookId = SetWindowsHookEx(WH_KEYBOARD_LL, m_Proc, GetModuleHandle(curModule.ModuleName), 0); } } }
public InputHook() { _keyboardHookHandlerDelegate = new HookHandlerDelegate(KeyboardHookCallback); using (Process curProcess = Process.GetCurrentProcess()) { using (ProcessModule curModule = curProcess.MainModule) { _keyboardHookID = NativeMethods.SetWindowsHookEx(WH_KEYBOARD_LL, _keyboardHookHandlerDelegate, NativeMethods.GetModuleHandle(curModule.ModuleName), 0); } } }
public KeyboardHook(Form1 frm) { m_F = frm; proc = new HookHandlerDelegate(HookCallback); using (Process curPro = Process.GetCurrentProcess()) using (ProcessModule curMod = curPro.MainModule) { hookID = SetWindowsHookExW(WH_KEYBOARD_LL, proc, GetModuleHandle(curMod.ModuleName), 0); } }
/// <summary> /// 挂上键盘钩子 /// </summary> private void KeyboardHook() { proc = new HookHandlerDelegate(HookCallback); using (Process curProcess = Process.GetCurrentProcess()) using (ProcessModule curModule = curProcess.MainModule) { hookID = SetWindowsHookEx(WH_KEYBOARD_LL, proc, GetModuleHandle(curModule.ModuleName), 0); if (hookID == IntPtr.Zero) { throw new System.Exception("没有足够权限安装钩子!"); } } }
public void Initiate() { proc = new HookHandlerDelegate(HookCallback); Mproc = new MHookHandlerDelegate(MHookCallback); using (Process curProcess = Process.GetCurrentProcess()) using (ProcessModule curModule = curProcess.MainModule) { hookID = NativeMethods.SetWindowsHookEx(WH_KEYBOARD_LL, proc, NativeMethods.GetModuleHandle(curModule.ModuleName), 0); MhookID = NativeMethods.SetWindowsHookEx(WH_MOUSE_LL, Mproc, NativeMethods.GetModuleHandle(curModule.ModuleName), 0); } }
public void Intercept() { if (_hookId == IntPtr.Zero) { _hookHandler = new HookHandlerDelegate(Hook); using (Process curProcess = Process.GetCurrentProcess()) using (ProcessModule curModule = curProcess.MainModule) { _hookId = NativeMethods.SetWindowsHookEx(WH_KEYBOARD_LL, _hookHandler, NativeMethods.GetModuleHandle(curModule.ModuleName), 0); } } }
public static void DisableSystemKeys() { if (callbackPtr == null) { callbackPtr = new HookHandlerDelegate(KeyboardHookHandler); } if (hookPtr == IntPtr.Zero) { // Note: This does not work in the VS host environment. To run in debug mode: // Project -> Properties -> Debug -> Uncheck "Enable the Visual Studio hosting process" IntPtr hInstance = Marshal.GetHINSTANCE(Application.CurrentCulture.GetType().Module); hookPtr = SetWindowsHookEx(LowLevelKeyboardHook, callbackPtr, hInstance, 0); } }
public void DisableSystemKeys() { if (callbackPtr == null) { callbackPtr = new HookHandlerDelegate(KeyboardHookHandler); } if (hookPtr == IntPtr.Zero) { // Note: This does not work in the VS host environment. To run in debug mode: // Project -> Properties -> Debug -> Uncheck "Enable the Visual Studio hosting process" IntPtr hInstance = Marshal.GetHINSTANCE(Application.Current.GetType().Module); hookPtr = SetWindowsHookEx(LowLevelKeyboardHook, callbackPtr, hInstance, 0); } }
public KeyboardHooker() { this.MappingOn = false; proc = new HookHandlerDelegate(this.HookCallback); using (Process curProcss = Process.GetCurrentProcess()) { using (ProcessModule curModule = curProcss.MainModule) { this.hookID = SetWindowsHookEx( WH_KEYBOARD_LL, proc, GetModuleHandle(curModule.ModuleName), 0); } } }
public Form1() { InitializeComponent(); Icon icon = Properties.Resources.AppIcon; this.Icon = icon; NotifyIcon1.Icon = icon; MainButton.BackColor = m_IsLock ? GreenColor : RedColor; m_Proc = new HookHandlerDelegate(HookCallback); using (Process curPro = Process.GetCurrentProcess()) using (ProcessModule curMod = curPro.MainModule) { SetWindowsHookExW(WH_KEYBOARD_LL, m_Proc, GetModuleHandle(curMod.ModuleName), 0); } }
private static extern int SetWindowsHookEx(int idHook, HookHandlerDelegate lpfn, IntPtr hMod, int dwThreadId);
/// <summary> /// 挂上键盘钩子 /// </summary> private void KeyboardHook() { proc = new HookHandlerDelegate(HookCallback); using (Process curProcess = Process.GetCurrentProcess()) using (ProcessModule curModule = curProcess.MainModule) { hookID = SetWindowsHookEx(WH_KEYBOARD_LL, proc, GetModuleHandle(curModule.ModuleName), 0); if (hookID == IntPtr.Zero) throw new System.Exception("没有足够权限安装钩子!"); } }
private static extern IntPtr SetWindowsHookEx(int idHook, HookHandlerDelegate callbackPtr, IntPtr hInstance, uint dwThreadId);
private static extern IntPtr SetWindowsHookEx(HookType idHook, HookHandlerDelegate lpfn, IntPtr hMod, uint dwThreadId);
private HookHandlerDelegate proc; //用于存储代理 #endregion Fields #region Constructors public KeyboardHook() { //this.Stream = stream; proc = new HookHandlerDelegate(HookCallback); IsHooked = false; }
public static extern IntPtr SetWindowsHookEx(int idHook, HookHandlerDelegate lpfn, IntPtr hMod, uint dwThreadId);
private static IntPtr SetHook(HookHandlerDelegate proc) { using (Process curProcess = Process.GetCurrentProcess()) { using (ProcessModule curModule = curProcess.MainModule) { return SetWindowsHookEx(WH_KEYBOARD_LL, proc, GetModuleHandle(curModule.ModuleName), 0); } } }
public static IntPtr SetLowLevelHook(HookHandlerDelegate callback) { return(SetWindowsHookEx(WH_KEYBOARD_LL, callback, IntPtr.Zero, 0)); }