急需各位大侠的帮助,一个关于消息截获的问题(200分)

  • 主题发起人 主题发起人 hanbinbin321
  • 开始时间 开始时间
H

hanbinbin321

Unregistered / Unconfirmed
GUEST, unregistred user!
[blue][/blue]问题是,windows消息中关于usb设备是否连接具体是哪一个?如何截获并处理该消息?
 
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>&nbsp; HWND hwnd, &nbsp; &nbsp; &nbsp; // handle to window<br>&nbsp; UINT uMsg, &nbsp; &nbsp; &nbsp; // WM_DEVICECHANGE<br>&nbsp; WPARAM wParam, &nbsp; // device-change event<br>&nbsp; LPARAM lParam &nbsp; &nbsp;// 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. &nbsp;<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. &nbsp;<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). &nbsp;<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>&nbsp; Windows NT/2000/XP: Included in Windows NT 4.0 and later.<br>&nbsp; Windows 95/98/Me: Included in Windows 95 and later.<br>&nbsp; Header: Declared in Winuser.h; include Windows.h.<br><br>
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
588
import
I
后退
顶部