WM_DEVICECHANGE message
Notifies an application of a change to the hardware configuration of a device or the computer.
A window receives this message through its WindowProc function.
LRESULT CALLBACK WindowProc(HWND hwnd, // handle to window
UINT uMsg, // WM_DEVICECHANGE
WPARAM wParam, // device-change event
LPARAM lParam ); // event-specific data
-
hwnd
-
A handle to the window.
-
uMsg
-
The WM_DEVICECHANGE identifier.
-
wParam
-
The event that has occurred. This parameter can be one of the following values from the Dbt.h header file.
Value Meaning DBT_DEVNODES_CHANGED
0x0007A device has been added to or removed from the system. DBT_QUERYCHANGECONFIG
0x0017Permission is requested to change the current configuration (dock or undock). DBT_CONFIGCHANGED
0x0018The current configuration has changed, due to a dock or undock. DBT_CONFIGCHANGECANCELED
0x0019A request to change the current configuration (dock or undock) has been canceled. DBT_DEVICEARRIVAL
0x8000A device or piece of media has been inserted and is now available. DBT_DEVICEQUERYREMOVE
0x8001Permission is requested to remove a device or piece of media. Any application can deny this request and cancel the removal. DBT_DEVICEQUERYREMOVEFAILED
0x8002A request to remove a device or piece of media has been canceled. DBT_DEVICEREMOVEPENDING
0x8003A device or piece of media is about to be removed. Cannot be denied. DBT_DEVICEREMOVECOMPLETE
0x8004A device or piece of media has been removed. DBT_DEVICETYPESPECIFIC
0x8005A device-specific event has occurred. DBT_CUSTOMEVENT
0x8006A custom event has occurred. DBT_USERDEFINED
0xFFFFThe meaning of this message is user-defined. -
lParam
-
A 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.
Return TRUE to grant the request.
Return BROADCAST_QUERY_DENY to deny the request.
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.
Requirement | Value |
---|---|
Minimum supported client | Windows XP |
Minimum supported server | Windows Server 2003 |
Header |
|