Here is the draft of a forthcoming article on this issue.
Q259697 - HOWTO: Force Reenumeration of a Device Tree From an Application
The information in this article applies to:
Microsoft Windows 2000 Driver Development Kit (DDK)
SUMMARY
This article demonstrates how to force reenumeration of a device and all
it’s children by using CM_Reenumerate_DevNode(). This is required if you
want to programmatically reenumerate devices on certain legacy buses such as
Serial, which cannot detect hot-plugin devices.
MORE INFORMATION
Following code snippet shows how to reenumerate entire device tree. This is
the programmatic equivalent of selecting the menu item “Scan For Hardware
Changes” from within the Device Manager.
BOOL ScanForHardwareChanges()
{
DEVINST devInst;
CONFIGRET status;
//
// Get the root devnode.
//
status = CM_Locate_DevNode(&devInst, NULL, CM_LOCATE_DEVNODE_NORMAL);
if (status != CR_SUCCESS) {
printf(“CM_Locate_DevNode failed: %x\n”, status);
return FALSE;
}
status = CM_Reenumerate_DevNode(devInst, 0);
if (status != CR_SUCCESS) {
printf(“CM_Reenumerate_DevNode failed: %x\n”, status));
return FALSE;
}
return TRUE;
}
Above 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 is expensive and would take 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 handle to it’s device
instance. For additional information on how to retrieve 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:
Q259695 HOWTO: Enumerate hardware devices 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.
-----Original Message-----
From: Maxim S. Shatskih [mailto:xxxxx@storagecraft.com]
Sent: Thursday, November 09, 2000 11:40 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Kicking off an IoInvalidateRelations from User mode
CM_Reenumerate_Devnode
(I’m not sure I spelled it correctly )
----- Original Message -----
From: “Nemiroff, Daniel”
To: “NT Developers Interest List”
Sent: Thursday, November 09, 2000 9:44 PM
Subject: [ntdev] Kicking off an IoInvalidateRelations from User mode
> Does anyone know the Win32 call that does the equivalent of going into
> DeviceManager and selected “Scan for Hardware Changes”?
>
> thanks,
>
> daniel
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to $subst(‘Email.Unsub’)
>
—
You are currently subscribed to ntdev as: xxxxx@microsoft.com
To unsubscribe send a blank email to $subst(‘Email.Unsub’)