Click here to Skip to main content
15,908,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
We have new PCs that have Windows 10 or Windows Server 2019 installed. Cards can now be plugged into certain PCI buses. I want to find out on which PCI bus a card is plugged in.

Does anyone have an idea how to find out relatively reliably under C# on which bus an adapter card is on the mainboard and where not? Is there a way that reflects the bus number of the mainboard layout?
Only technologies that can be used on a Windows system without additional installation may be used. Currently I am using at least .Net Framework 4.5.2.

What I have tried:

In my experiments I found out the following:
I can determine in Device Manager when a Card is installed or have problems. If it has problems most time the manufacturer driver is not installed. In this case it is impossible to detect the PCI bus of the problematic adapter card.
I tried the solution posted on Determine what (if any) PCI devices are plugged into motherboard PCI(e) slots[^].
Unfortunately, the WMI class Win32_SystemSlots is not suitable. The CurrentUsage property only shows Available because the cards are only plugged in but not actively used. InUse is only displayed if an inserted card is actively used. Many properties of this class (e.g. SlotDesignation) depend on what the manufacturer wrote into the SMBIOS. So unfortunately not reliable and usable.
Unfortunately, the combination/use of the WMI classes WIN32_SystemSlots, WMI32_Bus, WMI32_DeviceBus and WMI_PNPEntity is of no use either, since no clear references can be made here and the bus enumeration does not correspond to that on the mainboard. The same applies to the BusNumber/BusNum property.
Updated 23-Nov-22 21:36pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900