/// <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; } }
/// <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 DeviceEvent(DeviceNotification.DeviceEventInfo e) { this.Log(EventLogEntryType.Information, string.Format("DeviceEvent {0}", e)); }
internal void ServiceSendDeviceEvent(DeviceNotification.DeviceEventInfo e) { this.DeviceEvent(e); }
protected abstract void DeviceEvent(DeviceNotification.DeviceEventInfo e);