2,640
社区成员
发帖
与我相关
我的任务
分享
case WM_DEVICECHANGE:
::MessageBox(NULL,"检测到","waring",MB_ICONWARNING);
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
TCHAR szHello[MAX_LOADSTRING];
LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
char *str = "WM_DEVICECHANGE" ;
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
RECT rt;
GetClientRect(hWnd, &rt);
DrawText(hdc, "检测U盘" , strlen("检测U盘"), &rt, DT_CENTER);
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
////////////////////////////////////////////////////////////
case WM_DEVICECHANGE:
if (DBT_DEVICEARRIVAL==wParam )
::MessageBox(NULL,"U盘插入","waring",MB_ICONWARNING);
else if (DBT_DEVICEREMOVEPENDING==wParam || DBT_DEVICEREMOVECOMPLETE ==wParam)
::MessageBox(NULL,"U盘拔出","waring",MB_ICONWARNING);
////////////////////////////////////////////////////////////
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}