USB的连接和拔出等都会触发一系列WM_DEVICECHANGE消息<br>我从MSDN上摘抄一段给你!<br><br>WM_DEVICECHANGE<br>The WM_DEVICECHANGE device message notifies an application of a change to the hardware configuration of a device or the computer.<br><br>A window receives this message through its WindowProc function. <br><br>LRESULT CALLBACK WindowProc(<br> HWND hwnd, // handle to window<br> UINT uMsg, // WM_DEVICECHANGE<br> WPARAM wParam, // device-change event<br> LPARAM lParam // event-specific data<br>);<br>Parameters<br>wParam <br>Specifies the event. This parameter can be one of the following values. Value Meaning <br>DBT_CONFIGCHANGECANCELED A request to change the current configuration (dock or undock) has been canceled. <br>DBT_CONFIGCHANGED The current configuration has changed, due to a dock or undock. <br>DBT_CUSTOMEVENT Windows 98/Me, Windows 2000/XP: A custom event has occurred. <br>DBT_DEVICEARRIVAL A device has been inserted and is now available. <br>DBT_DEVICEQUERYREMOVE Permission is requested to remove a device. Any application can deny this request and cancel the removal. <br>DBT_DEVICEQUERYREMOVEFAILED A request to remove a device has been canceled. <br>DBT_DEVICEREMOVECOMPLETE A device has been removed. <br>DBT_DEVICEREMOVEPENDING A device is about to be removed. Cannot be denied. <br>DBT_DEVICETYPESPECIFIC A device-specific event has occurred. <br>DBT_DEVNODES_CHANGED Windows 2000/XP: A device has been added to or removed from the system. <br>DBT_QUERYCHANGECONFIG Permission is requested to change the current configuration (dock or undock). <br>DBT_USERDEFINED The meaning of this message is user-defined. <br><br><br>lParam <br>Pointer to a structure that contains event-specific data. Its format depends on the value of the wParam parameter. For more information, refer to the documentation for each event. <br>Return Values<br>Return TRUE to grant the request.<br><br>Return BROADCAST_QUERY_DENY to deny the request.<br><br>Remarks<br>For devices that offer software-controllable features, such as ejection and locking, the system typically sends a DBT_DEVICEREMOVEPENDING message to let applications and device drivers end their use of the device gracefully. If the system forcibly removes a device, it may not send a DBT_DEVICEQUERYREMOVE message before doing so.<br><br>Requirements <br> Windows NT/2000/XP: Included in Windows NT 4.0 and later.<br> Windows 95/98/Me: Included in Windows 95 and later.<br> Header: Declared in Winuser.h; include Windows.h.<br><br>