public SystemHook(SystemEventCallback callback, uint eventId)
 {
     this.callback    = callback;
     this.detachEvent = new AutoResetEvent(false);
     this.detachResultAvailableEvent = new AutoResetEvent(false);
     this.eventId = eventId;
     this.Id      = Guid.NewGuid();
 }
Example #2
0
        internal Guid RegisterSystemEvent(SystemEventCallback callback, uint eventId)
        {
            var hookId         = default(Guid);
            var hookReadyEvent = new AutoResetEvent(false);
            var hookThread     = new Thread(() =>
            {
                var hook = new SystemHook(callback, eventId);

                hook.Attach();
                hookId = hook.Id;
                SystemHooks[hookId] = hook;
                hookReadyEvent.Set();
                hook.AwaitDetach();
            });

            hookThread.SetApartmentState(ApartmentState.STA);
            hookThread.IsBackground = true;
            hookThread.Start();

            hookReadyEvent.WaitOne();

            return(hookId);
        }
Example #3
0
 public Guid RegisterSystemForegroundEvent(SystemEventCallback callback)
 {
     return(RegisterSystemEvent(callback, Constant.EVENT_SYSTEM_FOREGROUND));
 }
Example #4
0
 public Guid RegisterSystemCaptureStartEvent(SystemEventCallback callback)
 {
     return(RegisterSystemEvent(callback, Constant.EVENT_SYSTEM_CAPTURESTART));
 }