Check the C # Class Library: USBClassLibrary for USB device plugging

Source: Internet
Author: User
Tags manage connection

This is a USB library developed using C #, which enables you to manage connection and separation events of USB devices and detect your own devices. It can run in Windows XP and Windows 7 64-bit systems.

01 private void USBPort_USBDeviceAttached(objectsender,
02              USBClass.USBDeviceEventArgs e)
03 {
04    if (!MyUSBDeviceConnected)
05    {
06       if(USBClass.GetUSBDevice(MyDeviceVID, MyDevicePID,
07                                 ref USBDeviceProperties, false))
08       {
09          //My Device is connected
10          MyUSBDeviceConnected = true;
11       }
12    }
13 }
14  
15 private void USBPort_USBDeviceRemoved(objectsender,
16              USBClass.USBDeviceEventArgs e)
17 {
18    if(!USBClass.GetUSBDevice(MyDeviceVID, MyDevicePID,
19                               ref USBDeviceProperties, false))
20    {
21       //My Device is removed
22       MyUSBDeviceConnected = false;
23    }
24 }

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.