Beispiel #1
0
        public GlobalHookBase(GlobalHookTypes Type, bool OnThread)
        {
            this.HookType = Type;
            del           = ProcessMessage;
            if (OnThread)
            {
                hook = NativeMethod.SetWindowsHookEx(Type, del, IntPtr.Zero, NativeMethod.GetCurrentThreadId());
            }
            else
            {
                var hmod = IntPtr.Zero; // Marshal.GetHINSTANCE(GetType().Module);
                hook = NativeMethod.SetWindowsHookEx(Type, del, hmod, IntPtr.Zero);
            }

            if (hook == IntPtr.Zero)
            {
                int    err = Marshal.GetLastWin32Error();
                string msg = err.GetErrorMessage();

                if (err != 0)
                {
                    throw new Exception("Hookに失敗しました : " + msg);
                }
            }
        }
Beispiel #2
0
Datei: WMSG.cs Projekt: Chtau/AWC
        /*public WMSG(GlobalHookTypes Type):this(Type,false)
         * {
         * }*/

        public WMSG(GlobalHookTypes Type, bool OnThread, IntPtr handle)
        {
            this.HookType = Type;
            this.HookId   = (int)Type;
            del           = ProcessMessage;
            if (OnThread)
            {
                hook = SetWindowsHookEx(HookId, del, IntPtr.Zero, handle);//GetCurrentThreadId()
            }
            else
            {
                var hmod = IntPtr.Zero; // Marshal.GetHINSTANCE(GetType().Module);
                hook = SetWindowsHookEx(HookId, del, hmod, IntPtr.Zero);
            }

            if (hook == IntPtr.Zero)
            {
                int err = Marshal.GetLastWin32Error();
                if (err != 0)
                {
                    OnHookFailed(err);
                }
            }
        }
Beispiel #3
0
 public GlobalHookBase(GlobalHookTypes Type) : this(Type, false)
 {
 }
 public GlobalHookTrapper(GlobalHookTypes Type) : this(Type, false)
 {
 }
Beispiel #5
0
 public static extern IntPtr SetWindowsHookEx(GlobalHookTypes idHook, MessageDelegate lpfn, IntPtr hmod, IntPtr dwThreadId);
Beispiel #6
0
 public static extern IntPtr SetWindowsHookEx(GlobalHookTypes hookType, KeyboardHookDelegate hookDelegate, IntPtr hInstance, uint threadId);