1.添加动静
动静照射
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 == 灭茬)
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.
手动添加吧