How do I enumerate all hardware node in Windows 95/98?
The Windows 95 Plug and Play subsystem models the buses and installed physical devices using a set of devnodes. A devnode is just a data structure that contains information about the state of the device, such as its hardware ID and its configuration.
Devnodes also describe how the corresponding device is related to other buses and devices in the system. Each devnode has a parent, which is typically the devnode of the bus on which the corresponding device resides. Devnodes for buses also have parents, because the buses in a computer system can be thought of as being hierarchically bridged together. Taken together, the set of linked devnodes form a tree structure known as the hardware tree.
The hardware tree is a dynamic description of all the active buses and devices in the system. The operating system builds this tree as devices are detected, and maintains it continuously as devices are added and removed. Unlike the registry, which stores similar information for all enumerated devices in a relatively flat structure, the hardware tree dynamically models in a hierarchical fashion the interconnections of currently present devices.
Occasionally, a driver developer needs to walk the hardware tree. This would be necessary for building a list of active devices, for determining if a particular hardware resource is in use, or for determining the bus topology of the system. You can use this code in a device driver to walk the hardware tree:
typedef VOID (*TREEWALKCALLBACK)(DEVNODE DevNode);
VOID WalkHardwareTree(DEVNODE Node, TREEWALKCALLBACK NodeCallback)
DEVNODE Child, Sibling;
// if paramter Node is NULL, the caller is initializing the
// walk. To initialize the walk, we get the root devnode by
// calling CONFIGMG_Locate_DevNode with NULL as the hardware ID.
if (Node == 0)
CONFIGMG_Locate_DevNode(&Node, NULL, 0);
// If the root is not found, something is very wrong!
// Terminate the attempted walk by returning.
if (Node == 0)
// At this point we have a devnode, so let the callback Know about it.
// Now see if it has any children. If not, just return.
if ( CONFIGMG_Get_Child(&Child, Node, 0) != CR_SUCCESS)
// The node passed in has at least one child. Walk this subtree.
// Now walk subtree of any siblings.
while ( CONFIGMG_Get_Sibling(&Sibling, Child, 0) == CR_SUCCESS )
Child = Sibling;