日期:2014-05-17 浏览次数:21468 次
const int DBT_DEVICEARRIVAL = 0x8000;
const int DBT_DEVICEREMOVECOMPLETE = 0x8004;
protected override void WndProc(ref Message m)
{
try
{
int i =m.WParam.ToInt32();
switch (i)
{
case DBT_DEVICEARRIVAL:
DriveInfo[] s = DriveInfo.GetDrives();
foreach (DriveInfo drive in s)
{
if (drive.DriveType == DriveType.Removable)
{
MessageBox.Show("USB插入");
break;
}
}
break;
case DBT_DEVICEREMOVECOMPLETE:
//
MessageBox.Show("USB卸载");
break;
default:
break;