U盘识别操作

LRESULT   CTestUSBDlg::WindowProc(UINT   message,   WPARAM   wParam,   LPARAM   lParam)  
{
if(message   ==   WM_DEVICECHANGE)   //0x8000,0x8004
{
CString   str;
DEV_BROADCAST_HDR*   dhr   =   (DEV_BROADCAST_HDR   *)lParam;
switch(wParam)
{
case   DBT_CONFIGCHANGECANCELED:
TRACE( "DBT_CONFIGCHANGECANCELED ");
break;
case   DBT_CONFIGCHANGED:
TRACE( "DBT_CONFIGCHANGED ");
break;
case   DBT_DEVICEQUERYREMOVE:
TRACE( "DBT_DEVICEQUERYREMOVE ");
break;
case   DBT_DEVICEQUERYREMOVEFAILED:
TRACE( "DBT_DEVICEQUERYREMOVEFAILED ");
break;
case   DBT_DEVICEREMOVEPENDING:
TRACE( "DBT_DEVICEREMOVEPENDING ");
break;
case   DBT_DEVICETYPESPECIFIC:
TRACE( "DBT_DEVICETYPESPECIFIC ");
break;
case   DBT_QUERYCHANGECONFIG:
TRACE( "DBT_QUERYCHANGECONFIG ");
break;
case   DBT_USERDEFINED:
TRACE( "DBT_USERDEFINED ");
break;
case   DBT_DEVICEARRIVAL:
if(dhr-> dbch_devicetype   ==   DBT_DEVTYP_VOLUME)
{
PDEV_BROADCAST_VOLUME   lpdbv   =   (PDEV_BROADCAST_VOLUME)dhr;
if(lpdbv-> dbcv_flags   &   DBTF_MEDIA)
{
str.Format( "Drive   %c   插入 ",   FirstDriveFromMask(lpdbv   -> dbcv_unitmask));
//AfxMessageBox(str);
}
else
{
char   ch   =   FirstDriveFromMask(lpdbv   -> dbcv_unitmask);
str.Format( "%c:\\ ",ch);
}
}
break;
case   DBT_DEVICEREMOVECOMPLETE:
if(dhr-> dbch_devicetype   ==   DBT_DEVTYP_VOLUME)
{
PDEV_BROADCAST_VOLUME   lpdbv   =   (PDEV_BROADCAST_VOLUME)dhr;
if(lpdbv-> dbcv_flags   &   DBTF_MEDIA)
{
str.Format( "Drive   %c   拔除 ",FirstDriveFromMask(lpdbv   -> dbcv_unitmask));
}
else
{
str.Format( "Drive   %c   拔除 ",FirstDriveFromMask(lpdbv   -> dbcv_unitmask));
}
//AfxMessageBox(str);
}
break;
default:
break;
}
}
return   CDialog::WindowProc(message,   wParam,   lParam);
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值