The CM_Query_And_Remove_SubTree function checks whether a device instance and its children can be removed and, if so, it removes them.
CMAPI CONFIGRET CM_Query_And_Remove_SubTreeW( DEVINST dnAncestor, PPNP_VETO_TYPE pVetoType, LPWSTR pszVetoName, ULONG ulNameLength, ULONG ulFlags );
Caller-supplied device instance handle to the device at the root of the subtree to be removed. This device instance handle is bound to the local machine.
(Optional) If not NULL, this points to a location that, if the removal request fails, receives a PNP_VETO_TYPE-typed value indicating the reason for the failure.
(Optional) If not NULL, this is a caller-supplied pointer to a string buffer that receives a text string. The type of information this string provides is dependent on the value received by pVetoType. For information about these strings, see PNP_VETO_TYPE.
Caller-supplied value representing the length (number of characters) of the string buffer supplied by pszVetoName. This should be set to MAX_PATH.
A bitwise OR of the caller-supplied flag constants that are described in the Remarks section.
If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.
The purpose of the CM_Query_And_Remove_SubTree function is to allow an application to prepare a device for safe removal from the local machine. Use this function to remove devices only if a driver has not set the SurpriseRemovalOK member of DEVICE_CAPABILITIES. If a driver has set SurpriseRemovalOK, the application should call CM_Request_Device_Eject instead of CM_Query_And_Remove_SubTree.
CM_Query_And_Remove_SubTree supports setting the flags parameter ulFlags with one of the following two flags; these flags apply only if Windows or an installer vetoes the removal of a device:
Beginning with Windows XP, CM_Query_And_Remove_SubTree also supports setting the following additional flag; this flag applies only if the function successfully removes the device instance:
Windows applications that do not require the low-level operation CM_Query_And_Remove_SubTree should use the DIF_PROPERTYCHANGE request to disable a device instead of using CM_Query_And_Remove_SubTree to remove a device. The DIF_PROPERTYCHANGE request can be used to enable, disable, restart, stop, or change the properties of a device.
Callers of this function must have SeLoadDriverPrivilege. (Privileges are described in the Microsoft Windows SDK documentation.)
For information about using device instance handles that are bound to the local machine, see CM_Get_Child.
|Minimum supported client||Available in Microsoft Windows 2000 and later versions of Windows.|
|Header||cfgmgr32.h (include Cfgmgr32.h)|