#include
LRESULT CMFCApplication1Dlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
// TODO: 在此添加專用代碼和/或調用基類
PDEV_BROADCAST_HDR lpdb = (PDEV_BROADCAST_HDR)lParam;
PDEV_BROADCAST_VOLUME lpdbv = (PDEV_BROADCAST_VOLUME)lpdb;
TCHAR szMsg[80];
char driveName;
switch (message)
{
case WM_DEVICECHANGE:
switch (wParam)
{
case DBT_DEVICEARRIVAL:
::MessageBox(0, _T("檢測到USB設備"), _T("WM_DEVICECHANGE"), MB_OK);
break;
case DBT_DEVICEREMOVECOMPLETE:
::MessageBox(0, _T("USB設備拔出"), TEXT("WM_DEVICECHANGE"), MB_OK);
break;
default:
;
}
break;
default:
;
}
return CDialogEx::WindowProc(message, wParam, lParam);
}
分享標題:檢測USB設備變化
新聞來源:
http://weahome.cn/article/pgdhop.html