//动态监测设备插拔
#include <Dbt.h>
BEGIN_MESSAGE_MAP(ParticipateMeeting, CDialogEx)
ON_WM_DEVICECHANGE()
END_MESSAGE_MAP()
afx_msg BOOL OnDeviceChange(UINT nEventType, DWORD dwData);
BOOL ParticipateMeeting::OnDeviceChange(UINT nEventType, DWORD dwData)
{
DEV_BROADCAST_DEVICEINTERFACE * dbd = (DEV_BROADCAST_DEVICEINTERFACE*)dwData;
switch (nEventType)
{
case DBT_DEVICEARRIVAL:
MessageBox(L"Device arrival!");
break;
case DBT_DEVICEQUERYREMOVE:
// Handle device removal request
MessageBox(L"Device request remove!");
break;
case DBT_DEVICEREMOVECOMPLETE:
// Handle device removal
MessageBox(L"Device removal!");
break;
case DBT_DEVNODES_CHANGED:
//
MessageBox(L"DBT_DEVNODES_CHANGED");
break;
case DBT_DEVTYP_DEVICEINTERFACE:
//
MessageBox(L"DBT_DEVTYP_DEVICEINTERFACE");
break; case DBT_DEVTYP_HANDLE:
//
MessageBox(L"DBT_DEVTYP_HANDLE");
break; case DBT_DEVTYP_OEM:
//
MessageBox(L"DBT_DEVTYP_OEM");
break; case DBT_DEVTYP_PORT:
//
MessageBox(L"DBT_DEVTYP_PORT");
break; case DBT_DEVTYP_VOLUME:
//
MessageBox(L"DBT_DEVTYP_VOLUME");
break; default:
MessageBox(L"others!");
break;
} return TRUE;
}
05-25 16:45