USB flash disk Detection

Source: Internet
Author: User

Public partial class form1: Form
{
Public const int wm_devicechange = 0x219;
Public const int dbt_devicearrival = 0x8000;
Public const int dbt_configchangecanceled = 0x0019;
Public const int dbt_configchanged = 0x0018;
Public const int dbt_customevent = 0x8006;
Public const int dbt_devicequeryremove = 0x8001;
Public const int dbt_devicequeryremovefailed = 0x8002;
Public const int dbt_deviceremovecomplete = 0x8004;
Public const int dbt_deviceremovepending = 0x8003;
Public const int dbt_devicetypespecific = 0x8005;
Public const int dbt_devnodes_changed = 0x0007;
Public const int dbt_querychangeconfig = 0x0017;
Public const int dbt_userdefined = 0 xFFFF;

Public form1 ()
{
Initializecomponent ();
}

Protected override void wndproc (ref message m)
{
If (M. MSG = wm_devicechange)
{
Stringbuilder STR = new stringbuilder ();
Switch (M. wparam. toint32 ())
{

Case dbt_devnodes_changed:
Driveinfo [] drivers = driveinfo. getdrives ();
Foreach (driveinfo info in drivers)
{
If (info. drivetype = drivetype. removable)
{
Str. append ("drive letter:" + info. Name );
}
}
MessageBox. Show (Str. tostring ());

Break;
}
}

Base. wndproc (ref m );
}
}

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.