/// <summary>
        /// Registers Power Notification
        /// </summary>
        private void RegisterPowerNotification(IntPtr handle, NotifyType notifyType, Guid powerSettings)
        {
            switch (notifyType)
            {
            case NotifyType.Window:
                _registeredPowerNotifications.Add(PowerNotification.RegisterPowerSettingNotification(handle, ref powerSettings, PowerNotification.DeviceNotifyType.DEVICE_NOTIFY_WINDOW_HANDLE));
                break;

            case NotifyType.Service:
                _registeredPowerNotifications.Add(PowerNotification.RegisterPowerSettingNotification(handle, ref powerSettings, PowerNotification.DeviceNotifyType.DEVICE_NOTIFY_SERVICE_HANDLE));
                break;
            }
        }
        /// <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);
        }
        /// <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);
        }
 protected override void PowerEvent(PowerNotification.PowerEventInfo e)
 {
     this.Log(EventLogEntryType.Information, string.Format("PowerEvent {0}", e));
 }
Beispiel #5
0
 internal void ServiceSendPowerEvent(PowerNotification.PowerEventInfo e)
 {
     PowerEvent(e);
 }
Beispiel #6
0
 protected abstract void PowerEvent(PowerNotification.PowerEventInfo e);