Example #1
0
 /// <summary>
 /// Registers this application, so it will be notified for usb events.
 /// </summary>
 /// <param name="Handle">a IntPtr, that is a handle to the application.</param>
 /// <example> This sample shows how to implement this method in your form.
 /// <code>
 ///protected override void OnHandleCreated(EventArgs e)
 ///{
 ///    base.OnHandleCreated(e);
 ///    usb.RegisterHandle(Handle);
 ///}
 ///</code>
 ///</example>
 public void RegisterHandle(IntPtr Handle)
 {
     usb_event_handle = Win32Usb.RegisterForUsbEvents(Handle, device_class);
     this.handle      = Handle;
     //Check if the device is already present.
     CheckDevicePresent();
 }
Example #2
0
        /// <summary>
        /// Unregisters this application, so it won't be notified for usb events.
        /// </summary>
        /// <returns>Returns if it wass succesfull to unregister.</returns>
        public bool UnregisterHandle()
        {
            if (this.handle != null)
            {
                return(Win32Usb.UnregisterForUsbEvents(this.handle));
            }

            return(false);
        }