public Boolean UnregisterDeviceNotification()
        {
            if (false == DeviceManagement.StopReceivingDeviceNotifications(m_pdeviceHandler))
            {
                m_strLastErrorInfo = "Failed to stop receiving HID device notifications!";
                return(false);
            }

            return(true);
        }
        ///  <summary>
        ///  Perform actions that must execute when the program ends.
        ///  </summary>

        private void ShutdownHid()
        {
            try
            {
                //  Close open handles to the device.

                if (!(hidHandle == null))
                {
                    if (!(hidHandle.IsInvalid))
                    {
                        hidHandle.Close();
                    }
                }

                if (!(readHandle == null))
                {
                    if (!(readHandle.IsInvalid))
                    {
                        readHandle.Close();
                    }
                }

                if (!(writeHandle == null))
                {
                    if (!(writeHandle.IsInvalid))
                    {
                        writeHandle.Close();
                    }
                }

                //  Stop receiving notifications.

                MyDeviceManagement.StopReceivingDeviceNotifications(deviceNotificationHandle);

                myDeviceDetected = false;
            }
            catch (Exception ex)
            {
                Tracer.Error(ex);
                throw;
            }
        }
Esempio n. 3
0
        private static void DisposeNIA()
        {
            try
            {
                //  Close open handles to the device.
                if (!(hidHandle == null))
                {
                    if (!(hidHandle.IsInvalid))
                    {
                        hidHandle.Close();
                    }
                }

                if (!(readHandle == null))
                {
                    if (!(readHandle.IsInvalid))
                    {
                        readHandle.Close();
                    }
                }

                if (!(writeHandle == null))
                {
                    if (!(writeHandle.IsInvalid))
                    {
                        writeHandle.Close();
                    }
                }

                //  Stop receiving notifications.
                DeviceManagement deviceManagement = new DeviceManagement();
                deviceManagement.StopReceivingDeviceNotifications(deviceNotificationHandle);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Mainform should call this function while closing in order to release usb
 /// resources and stop the system to send needless notifications
 /// to an already closed form
 /// </summary>
 public void ShutDownDevice()
 {
     device.CloseDeviceHandle();
     deviceManager.StopReceivingDeviceNotifications(deviceNotificationHandle);
 }