Enumerating PciBusNumber PciDeviceNumber PciFunctionNumber in C++

Posted on 2004-11-18
Last Modified: 2008-01-09


I know how to enumerate all network cards using the SetupDiGetClassDevs, SetupDiGetDeviceInstanceId and SetupDiGetDeviceRegistryProperty API calls. However I need to go a step further and get the PciBusNumber PciDeviceNumber PciFunctionNumber for each network adapter installed - any ideas?

Many thanks in advance, if you can please try to include sample code - I'm rather new to C++ ...
Question by:dcx45

    Author Comment

    Found the function - it's called

        IN PDEVICE_OBJECT  DeviceObject,
        IN DEVICE_REGISTRY_PROPERTY  DeviceProperty,
        IN ULONG  BufferLength,
        OUT PVOID  PropertyBuffer,
        OUT PULONG  ResultLength

    Now, how do I get hold of PDEVICE_OBJECT???? (Ok that changes my initial question a bit, but hopefully I'll get there...)

    Author Comment

    Right  foiund the funtction to get the pointer

        IN PUNICODE_STRING  ObjectName,
        IN ACCESS_MASK  DesiredAccess,
        OUT PFILE_OBJECT  *FileObject,
        OUT PDEVICE_OBJECT  *DeviceObject

    What format does the ObjectName need to be in - it's frustrating that MSDN doesn't include code samples for this
    LVL 6

    Accepted Solution

    For example
    RtlInitUnicodeString(&ObjName, L"\\Device\\00000050");

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
    In Easy String Encryption Using CryptoAPI in C++ ( I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now