public DeviceUsbServiceWatcher(string serviceName)
 {
     // This function call using ServiceBase.ServiceName causes AccessViolationException
     // when the system suspends and so make this class effectively unusable.
     // The service status handle obtained by this function matches ServiceBase.ServiceHandle
     // which is obtained by the same function inside ServiceBase class.
     _statusHandle = RegisterServiceCtrlHandlerEx(
         serviceName,
         HandlerProc,
         IntPtr.Zero);
     if (_statusHandle != IntPtr.Zero)
     {
         _notificationHandle = DeviceUsbHelper.RegisterServiceNotification(_statusHandle);
     }
 }
Exemplo n.º 2
0
 public DeviceUsbWindowWatcher()
 {
     _listener           = new MessageOnlyWindowListener(this);
     _notificationHandle = DeviceUsbHelper.RegisterWindowNotification(_listener.Handle);
 }