const int WM_DEVICECHANGE = x;
const int DBT_DEVICEARRIVAL = x;
const int DBT_DEVICEREMOVECOMPLETE = x;
protected override void WndProc(ref Message m)
{
try
{
//if (mMsg == WM_DEVICECHANGE)
//{
switch (mWParamToInt())
{
case DBT_DEVICEARRIVAL: // U盘插入
DriveInfo[] s = DriveInfoGetDrives();
foreach (DriveInfo drive in s)
{
if (driveDriveType == DriveTypeRemovable)
{
ConsoleWriteLine("USB插入");
break;
}
}
break;
case DBT_DEVICEREMOVECOMPLETE: //U盘卸载
//
ConsoleWriteLine("USB卸载");
break;
default:
break;
}
//}
}
catch (Exception ex)
{
MessageBoxShow(exMessage);
}
baseWndProc(ref m);
}