예제 #1
0
 /// <summary>
 /// Create hidden form for processing Windows messages about USB drives. You do not need to override WndProc in your form.
 /// </summary>
 public DeviceDetector(bool showForm = false)
 {
     detectorForm = new DeviceDetectorForm(this);
     if (showForm) detectorForm.Show();
     _RecipientHandle = detectorForm.Handle;
     //RegisterDeviceNotification(_RecipientHandle, DEV_BROADCAST_DEVICEINTERFACE, 0)
 }
예제 #2
0
 // The bulk of the clean-up code is implemented in Dispose(bool)
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         //UnregisterDeviceNotification(_RecipientHandle);
         detectorForm.Dispose();
         detectorForm = null;
     }
 }
예제 #3
0
 /// <summary>
 /// Create hidden form for processing Windows messages about USB drives. You do not need to override WndProc in your form.
 /// </summary>
 public DeviceDetector(bool showForm = false)
 {
     detectorForm = new DeviceDetectorForm(this);
     if (showForm)
     {
         detectorForm.Show();
     }
     _RecipientHandle = detectorForm.Handle;
     //RegisterDeviceNotification(_RecipientHandle, DEV_BROADCAST_DEVICEINTERFACE, 0)
 }
예제 #4
0
        /// <summary>
        /// Create hidden form for processing Windows messages about USB drives. You do not need to override WndProc in your form.
        /// </summary>
        public DeviceDetector(bool showForm = false)
        {
            DetectorForm = new DeviceDetectorForm(this);
            if (showForm)
            {
                DetectorForm.Show();
            }
            _RecipientHandle = DetectorForm.Handle;

            //uint DEVICE_NOTIFY_WINDOW_HANDLE = 0;
            //var notificationFilter = new DEV_BROADCAST_DEVICEINTERFACE();
            //notificationFilter.Initialize();
            //// Request to receive notifications about a class of devices.
            //notificationFilter.dbch_devicetype = DBCH_DEVICETYPE.DBT_DEVTYP_DEVICEINTERFACE;
            //// Specify the interface class to receive notifications about.
            //notificationFilter.dbch_classguid = Guid.Empty;
            //// Allocate memory for the buffer that holds the DEV_BROADCAST_DEVICEINTERFACE structure.
            //IntPtr devBroadcastDeviceInterfaceBuffer;
            //devBroadcastDeviceInterfaceBuffer = Marshal.AllocHGlobal(notificationFilter.dbch_size);
            //// Copy the DEV_BROADCAST_DEVICEINTERFACE structure to the buffer.
            //// Set fDeleteOld True to prevent memory leaks.
            //Marshal.StructureToPtr(notificationFilter, devBroadcastDeviceInterfaceBuffer, true);
            //NativeMethods.RegisterDeviceNotification(_RecipientHandle, devBroadcastDeviceInterfaceBuffer, DEVICE_NOTIFY_WINDOW_HANDLE);
        }
예제 #5
0
 // The bulk of the clean-up code is implemented in Dispose(bool)
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         //UnregisterDeviceNotification(_RecipientHandle);
         detectorForm.Dispose();
         detectorForm = null;
     }
 }