Skip to main content

 none
getting a device tree with api RRS feed

  • Question

  • I have a few devices connected to my computer and I'm trying to get their device tree(including device Parent and Children like device manager).

    I need to fetch this device tree from a code (prefer python or cmd)

    I tried devcon but did not find any suited functionality.

    appreciate your help. need it ASAP

    Thanks a lot in a advance.

    • Moved by Jayden Gu Tuesday, July 11, 2017 2:05 AM not related to UWP
    • Moved by Dave PatrickMVP Tuesday, July 11, 2017 4:06 AM
    Monday, July 10, 2017 8:06 AM

All replies

  • Hi Rav55,

    You should be able to tell us more detail about what kind of API do you want. This forum is ask question related to develop Universal Windows apps.


    Best Regards,

    Jayden Gu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, July 11, 2017 2:49 AM
  • Hi Rav55,

    Thank you for posting MSDN forum.

    You could try to use the an SP_DEVINFO_DATAstructure for the parent of a device that has a device node (devnode) in the device tree. 

    if you want to manage the device tree that keeps track of the devices in the system, you need to use the PnP.

    Each node of the device tree is called a device node, or devnode. A devnode consists of the device objects for the device's drivers, plus internal information maintained by the system.

    The PnP manager asks a bus driver for a list of its child devices using an IRP_MN_QUERY_DEVICE_RELATIONS request. The bus driver determines its list of children according to its bus protocol. For example, the Windows ACPI driver,

    The above information explains how to access the device tree using code.

    If you want to get the device tree that be inserted on your computer. You could reference the below demo.

    Enumerate Installed Devices Using Setup API

    Best Regards,

    Hart


    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, July 18, 2017 7:14 AM
    Moderator
  • To get the device's parent, call CM_Get_Parent  (it is from a different set of APIs and Devcon does not demonstrate its use - but Microsoft be Microsoft... cope with them.)

    -- pa

    Tuesday, July 18, 2017 3:56 PM