做这个USB的插拔事件已经3个多星期了(再作不下去要被炒鱿鱼了)。
zhou80bin(彬彬)你以前的方法也用过(http://expert.csdn.net/Expert/topic/1160/1160416.xml?temp=.4244043),不过好像只能知道USB口上有变化,也用过GetCurrentHwProfile(&HwProfInfo)
不过 HwProfInfo.dwDockInfo的值一直等于7,所以也无法判断插还是拔。
TO zhou80bin(彬彬):
你说你的问题解决了,正替你高兴!恳请直待指点,在下感激不尽,感激不尽!
TO ALL:
不会的UP一下也行,感激不尽~
会的, 恳请直待指点,感激不尽,感激不尽!
zhou80bin(彬彬)你以前的方法也用过(http://expert.csdn.net/Expert/topic/1160/1160416.xml?temp=.4244043),不过好像只能知道USB口上有变化,也用过GetCurrentHwProfile(&HwProfInfo)
不过 HwProfInfo.dwDockInfo的值一直等于7,所以也无法判断插还是拔。
TO zhou80bin(彬彬):
你说你的问题解决了,正替你高兴!恳请直待指点,在下感激不尽,感激不尽!
TO ALL:
不会的UP一下也行,感激不尽~
会的, 恳请直待指点,感激不尽,感激不尽!
解决方案 »
- 急问急问啊!:托管类(ref)是否不能编译成静态库(.lib)给别人调用??
- ado如何用集成windows验证的方式登陆sql server,期待您的help!!
- 提醒大家不要去这个公司。(亲身经历)
- 饼图的打印问题
- 如何单击客户区(不是再标题上)移动窗体?
- 不知道怎么回事,我的debug版没有问题,但是release版有问题,更怪的是在release版下面用调试(F5)是没有问题,但是用执行(ctrl+F5)时
- 关于操作注册表 RegSaveKey RegLoadKey
- ADO连接ACCESS数据库问题?
- 你不一定会,不信试试
- 如何能打印主程序的client area ? (还要预览) 很急!!
- 高分求visual assist 6.0 build 1079的序列号????
- ***非常重要的问题 , 希望微软专家能帮忙解答 ...Asf 文件用DirectShow能进行 慢放/快进吗? ***
This topic pertains only to applications written in C++.
[C++]
Because universal serial bus (USB) devices can be added to and removed from the system without rebooting, you might want your application to be able to respond to a new configuration of input devices. For example, you might allow a new player to join a game in progress by plugging in another controller. To receive a message when a device is changed, you must first register for notification, as in the following code example:PVOID hNotifyDevNode;
void RegisterForDevChange(HWND hDlg, PVOID *hNotifyDevNode)
{
DEV_BROADCAST_DEVICEINTERFACE *pFilterData =
(DEV_BROADCAST_DEVICEINTERFACE*)
_alloca(sizeof(DEV_BROADCAST_DEVICEINTERFACE));
ASSERT (pFilterData);
ZeroMemory(pFilterData, sizeof(DEV_BROADCAST_DEVICEINTERFACE));
pFilterData->dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE);
pFilterData->dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
pFilterData->dbcc_classguid = GUID_CLASS_INPUT;
*hNotifyDevNode = RegisterDeviceNotification(hDlg, pFilterData,
DEVICE_NOTIFY_WINDOW_HANDLE);
}
Then, in your main window procedure, check for messages announcing that a device has been attached, is about to be removed, or has been removed, as follows:MyWindowProc(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam)
{
switch (nMsg)
{
case WM_DEVICECHANGE:
{
switch (wParam)
{
case DBT_DEVICEARRIVAL:
// Handle device arrival
break; case DBT_DEVICEQUERYREMOVE:
// Handle device removal request
break;
case DBT_DEVICEREMOVECOMPLETE:
// Handle device removal
break;
}
}
.
.
.
}
}
In response to a DBT_DEVICEARRIVAL event, obtain the instance GUID of the device by using IDirectInput7::FindDevice, and pass this value to IDirectInput7::CreateDeviceEx.For more information, see Device Management in the the Platform SDK.
Built on Wednesday, January 26, 2000
我也是这样做的,不过RegisterDeviceNotification好像没什么用,要不我把的源程序给你看看?
NotificationFilter.dbcc_classguid.Data1=0xff646f80;
NotificationFilter.dbcc_classguid.Data2=0x8def;
NotificationFilter.dbcc_classguid.Data3=0x11d2;
NotificationFilter.dbcc_classguid.Data4[0]=0x94;
NotificationFilter.dbcc_classguid.Data4[1]=0x49;
NotificationFilter.dbcc_classguid.Data4[2]=0x00;
NotificationFilter.dbcc_classguid.Data4[3]=0x10;
NotificationFilter.dbcc_classguid.Data4[4]=0x5a;
NotificationFilter.dbcc_classguid.Data4[5]=0x07;
NotificationFilter.dbcc_classguid.Data4[6]=0x5f;
NotificationFilter.dbcc_classguid.Data4[7]=0x6b;
{36FC9E60-C465-11CF-8056-444553540000}你可以在注册表中查询到的HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\USB\ROOT_HUB此键值下面有你的设备列表你可以查到的,只能用那个
值看到了,是不是把
dbcc_classguid 改成36FC9E60-C465-11CF-8056-444553540000
吗?
告诉我你的邮箱,或者 QQ,我把源程序给你看看,OK?
我发了!
正是太感谢你了!