做这个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一下也行,感激不尽~
      会的, 恳请直待指点,感激不尽,感激不尽!

解决方案 »

  1.   

    loopyifly(深情咸鱼) :谢谢
      

  2.   

    Recognizing Device Changes  [Language: C++][Visual Basic] 
    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
      

  3.   

    To isdong(有些事情应该忘记,有些事情值得回忆):
      我也是这样做的,不过RegisterDeviceNotification好像没什么用,要不我把的源程序给你看看?
      

  4.   

    那就是dbcc_classguid 的问题,首先检查这个东西对不对
      

  5.   

    dbcc_classguid :是USB设备厂商给我的,
     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;
      

  6.   

    我的USB为:
    {36FC9E60-C465-11CF-8056-444553540000}你可以在注册表中查询到的HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\USB\ROOT_HUB此键值下面有你的设备列表你可以查到的,只能用那个
      

  7.   

    36FC9E60-C465-11CF-8056-444553540000
    值看到了,是不是把
    dbcc_classguid 改成36FC9E60-C465-11CF-8056-444553540000
    吗?
      

  8.   

    我改了不过还是没有变化,跟以前一样
    告诉我你的邮箱,或者 QQ,我把源程序给你看看,OK?
      

  9.   

    To  isdong(有些事情应该忘记,有些事情值得回忆) :
        我发了!
    正是太感谢你了!
      

  10.   

    帮你up,都是高手阿,学习ing……