mirror of
https://github.com/ckaczor/Common.Native.git
synced 2026-02-08 17:24:32 -05:00
Initial commit
This commit is contained in:
39
WinHook.cs
Normal file
39
WinHook.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Common.Native
|
||||
{
|
||||
public class WinHook
|
||||
{
|
||||
public enum HookType
|
||||
{
|
||||
WH_JOURNALRECORD = 0,
|
||||
WH_JOURNALPLAYBACK = 1,
|
||||
WH_KEYBOARD = 2,
|
||||
WH_GETMESSAGE = 3,
|
||||
WH_CALLWNDPROC = 4,
|
||||
WH_CBT = 5,
|
||||
WH_SYSMSGFILTER = 6,
|
||||
WH_MOUSE = 7,
|
||||
WH_HARDWARE = 8,
|
||||
WH_DEBUG = 9,
|
||||
WH_SHELL = 10,
|
||||
WH_FOREGROUNDIDLE = 11,
|
||||
WH_CALLWNDPROCRET = 12,
|
||||
WH_KEYBOARD_LL = 13,
|
||||
WH_MOUSE_LL = 14
|
||||
}
|
||||
|
||||
public delegate IntPtr HookProc(int code, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
public static extern IntPtr SetWindowsHookEx(HookType hookType, HookProc lpfn, IntPtr hMod, uint dwThreadId);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool UnhookWindowsHookEx(IntPtr hhk);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user