Пример #1
0
        /// <summary>
        /// Registers a Device Notification
        /// </summary>
        private void RegisterDeviceNotification(IntPtr handle, NotifyType notifyType, Guid device)
        {
            switch (notifyType)
            {
            case NotifyType.Window:
                _registeredDeviceNotifications.Add(DeviceNotification.RegisterDeviceInterface(handle, DeviceNotification.DeviceNotifyType.DEVICE_NOTIFY_WINDOW_HANDLE | DeviceNotification.DeviceNotifyType.DEVICE_NOTIFY_ALL_INTERFACE_CLASSES, device));
                break;

            case NotifyType.Service:
                _registeredDeviceNotifications.Add(DeviceNotification.RegisterDeviceInterface(handle, DeviceNotification.DeviceNotifyType.DEVICE_NOTIFY_SERVICE_HANDLE, device));
                break;
            }
        }
Пример #2
0
        /// <summary>
        /// Unregisters all Device and Power Notifications previously registered with RegisterPowerNotification and RegisterDeviceNotification
        /// </summary>
        /// <param name="handle">Window handle</param>
        public void UnRegisterNotifications(IntPtr handle)
        {
            foreach (var item in _registeredDeviceNotifications)
            {
                DeviceNotification.UnregisterDeviceNotification(item);
            }

            foreach (var item in _registeredPowerNotifications)
            {
                PowerNotification.UnregisterPowerSettingNotification(item);
            }

            SessionNotification.WTSUnRegisterSessionNotificationEx(SessionNotification.WTS_CURRENT_SERVER, handle);
        }
Пример #3
0
        /// <summary>
        /// Transforms a Message to NotificationDetail
        /// </summary>
        public static NotificationDetail Transform(ref Message m)
        {
            NotificationDetail nd = new NotificationDetail();

            if (_ignoreMessages.Contains(m.Msg))
            {
                return(null);
            }

            nd.Power  = PowerNotification.TransformMessage(ref m);
            nd.Device = DeviceNotification.TransformMessage(ref m);
            if ((nd.Power != null) || (nd.Device != null))
            {
                return(nd);
            }

            return(null);
        }
Пример #4
0
 protected override void DeviceEvent(DeviceNotification.DeviceEventInfo e)
 {
     this.Log(EventLogEntryType.Information, string.Format("DeviceEvent {0}", e));
 }
Пример #5
0
 internal void ServiceSendDeviceEvent(DeviceNotification.DeviceEventInfo e)
 {
     this.DeviceEvent(e);
 }
Пример #6
0
 protected abstract void DeviceEvent(DeviceNotification.DeviceEventInfo e);