消息映射
BEGIN_MESSAGE_MAP(CAFT_1394Dlg, CDialog)
//{{AFX_MSG_MAP(CAFT_1394Dlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
...
ON_WM_DEVICECHANGE()
//}}AFX_MSG_MAP
声明消息响应函数:
afx_msg BOOL OnDeviceChange(UINT nEventType, DWORD dwData)
定义函数内容:
BOOL XXXXXXX::OnDeviceChange(UINT nEventType,DWORD dwData)
{
DEV_BROADCAST_DEVICEINTERFACE* dbd = (DEV_BROADCAST_DEVICEINTERFACE*) dwData
//这里进行信息匹配,比如guid等
//针对各个事件进行处理.
switch (nEventType)
{
case DBT_DEVICEREMOVECOMPLETE:
...
break
case DBT_DEVICEARRIVAL:
...
break
...
...
...
default:
break
}
return TRUE
}
2.注册设备
if (Handle == NULL)
return FALSE
DEV_BROADCAST_DEVICEINTERFACE DevInt
memset(&DevInt,0,sizeof(DEV_BROADCAST_DEVICEINTERFACE))
DevInt.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE)
DevInt.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE
DevInt.dbcc_classguid = GetCurrentUSBGUID()//m_usb->GetDriverGUID()
if (!RegisterDeviceNotification(m_hWnd, &DevInt,DEVICE_NOTIFY_WINDOW_HANDLE) )
return FALSE
只有注册了该设备,OnDeviceChange才能获得详细的信息,否则收到的参数都是0007.
手动添加吧
我也没找到
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)