I am working in C++ on Windows and trying to develop a tool that can identify which PCI slots are in use. I can read PCI config space to find the PCI devices that have slots and which of those slots are in use. I also need to know the form factor of the slots (CEM, M.2, U.2, Oculink). Is there anything in PCI config space that indicates the form factor of a slot?
You could try to use WMI to query Win32_SystemSlot
(see https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/win32-systemslot)
It contains a lot of info, but i think LengthAllowed
is what describes slot width and probably Model
is what you are looking for