Article ID: 259697 - View products that this article applies to.
This article was previously published under Q259697
This article demonstrates how to force reenumeration of a device and all it's children by using the CM_Reenumerate_DevNode function. Reenumeration is required if you want to programmatically reenumerate devices on certain legacy buses such as Serial, which cannot detect Plug and Play devices.
The following code snippet shows you how to reenumerate the entire device tree. This is the programmatic equivalent of clicking the Scan For Hardware Changes menu item in the Device Manager.
The preceding function results in IRP_MN_QUERY_DEVICE_RELATIONS (BusRelations) IRP being sent to all the devices in the device tree starting at root. This operation takes a few seconds to complete.
Instead of scanning the entire tree, you can cause a specific bus device and all it's children to be reenumerated if you have a handle to it's device instance. For additional information about how to retrieve a device instance handle of a particular device by using SetupDi API calls, click the article number below to view the article in the Microsoft Knowledge Base:
(http://support.microsoft.com/kb/259695/EN-US/ )How To Enumerate Hardware Devices by Using SetupDi Calls
The Config Manager APIs that require Device Instance Handle can use the DevInst value of the SP_DEVINFO_DATA structure returned by the SetupDiEnumDeviceInfo/SetupDiGetDeviceInterfaceDetail function.
For more information about Config Manager API calls, refer to the Windows 2000 DDK documentation.