2,643
社区成员
发帖
与我相关
我的任务
分享
Select Case uMsg
Case WM_DEVICECHANGE
If wParam = DBT_DEVICEREMOVECOMPLETE Then
MsgBox ("beep")
End If
End Select
Select Case uMsg
Case WM_DEVICECHANGE
MsgBox ("beep")
End Select
void CWndMessDlg::OnDeviceChange(WPARAM wParam,LPARAM lParam)
{
UINT Event = (UINT) wParam;
PDEV_BROADCAST_HDR pHDR = (PDEV_BROADCAST_HDR) lParam;
CString strMes ;
switch(Event) {
case DBT_CONFIGCHANGECANCELED:
strMes = "A request to change the current configuration (dock or undock) has been canceled. ";
break;
case DBT_CONFIGCHANGED:
strMes = "The current configuration has changed, due to a dock or undock.";
break;
case DBT_DEVICEARRIVAL:
strMes = "A device has been inserted and is now available. " ;
strMes += "\n";
switch(pHDR->dbch_devicetype) {
case DBT_DEVTYP_OEM :
strMes += "OEM- or IHV-defined device type. ";
break;
case DBT_DEVTYP_VOLUME: //这个是U盘
strMes += " Logical volume. ";
break;
case DBT_DEVTYP_PORT: //注意看这个,端口设备哦
strMes += " Port device (serial or parallel). ";
break;
default:
break;
}
break;
case DBT_DEVICEQUERYREMOVE :
strMes = "Permission is requested to remove a device. Any application can deny this request and cancel the removal. ";
break;
case DBT_DEVICEQUERYREMOVEFAILED:
strMes = "A request to remove a device has been canceled. ";
break;
case DBT_DEVICEREMOVECOMPLETE:
strMes = "A device has been removed. ";
break;
case DBT_DEVICEREMOVEPENDING:
strMes = "A device is about to be removed. Cannot be denied. ";
break;
case DBT_DEVICETYPESPECIFIC:
strMes = "A device-specific event has occurred. ";
break;
case DBT_QUERYCHANGECONFIG:
strMes = "Permission is requested to change the current configuration (dock or undock). ";
break;
case DBT_USERDEFINED:
strMes ="The meaning of this message is user-defined. ";
break;
default:
break;
}
AfxMessageBox(strMes);
}
Select Case uMsg
Case WM_DEVICECHANGE
If (DEV_BROADCAST_HDR)lParam.dbch_devicetype <> DBT_DEVTYP_VOLUME
Then
MsgBox ("beep")
End If
End Select