void PCIinfo()
{
DWORD dwSize, dwPropertyRegDataType;
HDEVINFO hDevInfo;
SP_DEVINFO_DATA DeviceInfoData;
DeviceInfoData.cbSize = sizeof(DeviceInfoData);
TCHAR szDesc[1024];
hDevInfo = SetupDiGetClassDevs(NULL, TEXT("PCI"), NULL, DIGCF_PRESENT | DIGCF_ALLCLASSES); // List all connected PCI devices
if (hDevInfo == INVALID_HANDLE_VALUE) return;
SP_DEVICE_INTERFACE_DATA device_interface = { 0 };
device_interface.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
for (int i = 0; ; i++)
{
if (!SetupDiEnumDeviceInfo(hDevInfo, i, &DeviceInfoData)) {
break;
}
printf("Dev description: ");
SetupDiGetDeviceRegistryProperty(hDevInfo,
&DeviceInfoData,
SPDRP_DEVICEDESC,
&dwPropertyRegDataType,
(BYTE*)szDesc,
sizeof(szDesc),
&dwSize);
printf("%s \n\n", szDesc);
printf("Bus number: ");
SetupDiGetDeviceRegistryProperty(hDevInfo,
&DeviceInfoData,
SPDRP_BUSNUMBER,
&dwPropertyRegDataType,
(BYTE*)szDesc,
sizeof(szDesc),
&dwSize);
printf("%d \n\n", szDesc[0]);
printf("\n\n");
}
}
reference:Detailed PCI-E information, Windows