详细的PCI-E信息,Windows

问题描述 投票:1回答:1

我有一个项目,我需要从带有图形卡的计算机中收集信息,从1到12,它有。然后将此信息保存在云中以供以后使用。

我需要的是,至少是:

它是什么GPU多少内存它使用哪个PCI插槽,1,2,3等(或者它的名字)

Windows WMI似乎有一些信息,我一直在寻找不同的类,但似乎很难找到PCI-E插槽。有谁知道如何获取这些信息?

graphics wmi pci
1个回答
1
投票

你应该寻找PCI插槽我没有在字符串中看到任何PCI-E定义(并不意味着没有)。如果我只尝试"PCI",结果会同时包含PCI和PCI-E设备。在BDS2006 C ++ / VCL中我只是通过更改匹配字符串来使用this(我很久以前就破坏了):

//---------------------------------------------------------------------------
//$$---- Form CPP ----
//---------------------------------------------------------------------------
#include <vcl.h>
#include <setupapi.h>
#pragma hdrstop
#include "win_main.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TMain *Main;
//---------------------------------------------------------------------------
bool USBinfo()
    {
    int i,n;
    AnsiString s,txt="";
    DWORD dwSize,dwPropertyRegDataType;
    HDEVINFO hDevInfo;
    SP_DEVINFO_DATA DeviceInfoData;
    TCHAR szDesc[1024];

//  hDevInfo = SetupDiGetClassDevs(NULL, NULL, NULL, DIGCF_PRESENT|DIGCF_ALLCLASSES);           // List all devices
//  hDevInfo = SetupDiGetClassDevs(NULL, TEXT("USB"), NULL, DIGCF_PRESENT|DIGCF_ALLCLASSES);    // List all connected USB devices
    hDevInfo = SetupDiGetClassDevs(NULL, TEXT("PCI"), NULL, DIGCF_PRESENT|DIGCF_ALLCLASSES);    // List all connected PCI devices
    if (hDevInfo == INVALID_HANDLE_VALUE) return false;
    // Find the ones that are driverless
    for (i=0;;i++)
        {
        DeviceInfoData.cbSize = sizeof(DeviceInfoData);
        if (!SetupDiEnumDeviceInfo(hDevInfo, i, &DeviceInfoData)) break;
        SetupDiGetDeviceRegistryProperty(hDevInfo, &DeviceInfoData, SPDRP_DEVICEDESC,&dwPropertyRegDataType, (BYTE*)szDesc,sizeof(szDesc),&dwSize);
        s=szDesc; n=48; while (s.Length()<n) s+=" "; if (s.Length()>n) s=s.SubString(1,n); txt+=s+" ";
        SetupDiGetDeviceRegistryProperty(hDevInfo, &DeviceInfoData, SPDRP_HARDWAREID,&dwPropertyRegDataType, (BYTE*)szDesc,sizeof(szDesc),&dwSize);
        s=szDesc; n=64; while (s.Length()<n) s+=" "; if (s.Length()>n) s=s.SubString(1,n); txt+=s+" ";
        SetupDiGetDeviceRegistryProperty(hDevInfo, &DeviceInfoData, SPDRP_LOCATION_INFORMATION,&dwPropertyRegDataType, (BYTE*)szDesc,sizeof(szDesc),&dwSize);
        s=szDesc; n=40; while (s.Length()<n) s+=" "; if (s.Length()>n) s=s.SubString(1,n); txt+=s+" ";
        txt+="\r\n";
        }
    Main->mm_log->Lines->Add(txt);
    return true;
    }
//-------------------------------------------------------------------------
__fastcall TMain::TMain(TComponent* Owner) : TForm(Owner)
    {
    USBinfo();
    }
//-------------------------------------------------------------------------

这里是"PCI"字符串的示例输出:

PCI standard host CPU bridge                     PCI\VEN_1022&DEV_1400&SUBSYS_00000000&REV_00                     PCI bus 0, device 24, function 0         
PCI standard host CPU bridge                     PCI\VEN_1022&DEV_1401&SUBSYS_00000000&REV_00                     PCI bus 0, device 24, function 1         
PCI standard host CPU bridge                     PCI\VEN_1022&DEV_1402&SUBSYS_00000000&REV_00                     PCI bus 0, device 24, function 2         
PCI standard host CPU bridge                     PCI\VEN_1022&DEV_1403&SUBSYS_00000000&REV_00                     PCI bus 0, device 24, function 3         
PCI standard host CPU bridge                     PCI\VEN_1022&DEV_1404&SUBSYS_00000000&REV_00                     PCI bus 0, device 24, function 4         
PCI standard host CPU bridge                     PCI\VEN_1022&DEV_1405&SUBSYS_00000000&REV_00                     PCI bus 0, device 24, function 5         
PCI standard host CPU bridge                     PCI\VEN_1022&DEV_1410&SUBSYS_14101022&REV_00                     PCI bus 0, device 0, function 0          
PCI Express standard Root Port                   PCI\VEN_1022&DEV_1412&SUBSYS_12341022&REV_00                     PCI bus 0, device 2, function 0          
PCI Express standard Root Port                   PCI\VEN_1022&DEV_1414&SUBSYS_12341022&REV_00                     PCI bus 0, device 4, function 0          
PCI Express standard Root Port                   PCI\VEN_1022&DEV_1417&SUBSYS_12341022&REV_00                     PCI bus 0, device 7, function 0          
AMD IOMMU Device                                 PCI\VEN_1022&DEV_1419&SUBSYS_14191022&REV_00                     PCI bus 0, device 0, function 2          
AMD SATA Controller                              PCI\VEN_1022&DEV_7801&SUBSYS_B0021458&REV_40                     PCI bus 0, device 17, function 0         
Standard OpenHCD USB Host Controller             PCI\VEN_1022&DEV_7807&SUBSYS_50041458&REV_11                     PCI bus 0, device 18, function 0         
Standard OpenHCD USB Host Controller             PCI\VEN_1022&DEV_7807&SUBSYS_50041458&REV_11                     PCI bus 0, device 19, function 0         
Standard Enhanced PCI to USB Host Controller     PCI\VEN_1022&DEV_7808&SUBSYS_50041458&REV_11                     PCI bus 0, device 18, function 2         
Standard Enhanced PCI to USB Host Controller     PCI\VEN_1022&DEV_7808&SUBSYS_50041458&REV_11                     PCI bus 0, device 19, function 2         
Standard OpenHCD USB Host Controller             PCI\VEN_1022&DEV_7809&SUBSYS_50041458&REV_11                     PCI bus 0, device 20, function 5         
AMD SMBus                                        PCI\VEN_1022&DEV_780B&SUBSYS_780B1022&REV_14                     PCI bus 0, device 20, function 0         
High Definition Audio Controller                 PCI\VEN_1022&DEV_780D&SUBSYS_A0021458&REV_01                     PCI bus 0, device 20, function 2         
PCI standard ISA bridge                          PCI\VEN_1022&DEV_780E&SUBSYS_780E1022&REV_11                     PCI bus 0, device 20, function 3         
PCI standard PCI-to-PCI bridge                   PCI\VEN_1022&DEV_780F&SUBSYS_00000000&REV_40                     PCI bus 0, device 20, function 4         
AMD USB 3.0 Host Controller                      PCI\VEN_1022&DEV_7812&SUBSYS_50041458&REV_03                     PCI bus 0, device 16, function 0         
AMD USB 3.0 Host Controller                      PCI\VEN_1022&DEV_7812&SUBSYS_50041458&REV_03                     PCI bus 0, device 16, function 1         
High Definition Audio Controller                 PCI\VEN_10DE&DEV_0BEE&SUBSYS_35371458&REV_A1                     PCI bus 1, device 0, function 1          
NVIDIA GeForce GTX 550 Ti                        PCI\VEN_10DE&DEV_1244&SUBSYS_35371458&REV_A1                     PCI bus 1, device 0, function 0          
Realtek PCIe GBE Family Controller               PCI\VEN_10EC&DEV_8168&SUBSYS_E0001458&REV_06                     PCI bus 2, device 0, function 0          
MSI TV@Anywhere Plus                             PCI\VEN_1131&DEV_7133&SUBSYS_62311462&REV_D1                     PCI bus 4, device 6, function 0          
Etron USB 3.0 Extensible Host Controller         PCI\VEN_1B6F&DEV_7023&SUBSYS_50071458&REV_01                     PCI bus 3, device 0, function 0          

只是忽略VCL的东西。重要的是USBinfo()功能(是的,我用它来获取USB信息)。它将枚举所有设备(如在设备管理器中)匹配您启动它的字符串(其中3个类似的第2行补救)。要清楚AnsiString是字符串类(元素是从[1]而不是[0]访问)和DWORD是无符号32位int。 Main->mm_log只是TMemo,我输出结果。别忘了包括setupapi.h

该界面可以获取您在Windows设备管理器中找到的任何信息,只需使用您需要的SPDRP_属性(它们在setupapi.h中列出,这是我的包含:

#define SPDRP_DEVICEDESC                  (0x00000000)  // DeviceDesc (R/W)
#define SPDRP_HARDWAREID                  (0x00000001)  // HardwareID (R/W)
#define SPDRP_COMPATIBLEIDS               (0x00000002)  // CompatibleIDs (R/W)
#define SPDRP_UNUSED0                     (0x00000003)  // unused
#define SPDRP_SERVICE                     (0x00000004)  // Service (R/W)
#define SPDRP_UNUSED1                     (0x00000005)  // unused
#define SPDRP_UNUSED2                     (0x00000006)  // unused
#define SPDRP_CLASS                       (0x00000007)  // Class (R--tied to ClassGUID)
#define SPDRP_CLASSGUID                   (0x00000008)  // ClassGUID (R/W)
#define SPDRP_DRIVER                      (0x00000009)  // Driver (R/W)
#define SPDRP_CONFIGFLAGS                 (0x0000000A)  // ConfigFlags (R/W)
#define SPDRP_MFG                         (0x0000000B)  // Mfg (R/W)
#define SPDRP_FRIENDLYNAME                (0x0000000C)  // FriendlyName (R/W)
#define SPDRP_LOCATION_INFORMATION        (0x0000000D)  // LocationInformation (R/W)
#define SPDRP_PHYSICAL_DEVICE_OBJECT_NAME (0x0000000E)  // PhysicalDeviceObjectName (R)
#define SPDRP_CAPABILITIES                (0x0000000F)  // Capabilities (R)
#define SPDRP_UI_NUMBER                   (0x00000010)  // UiNumber (R)
#define SPDRP_UPPERFILTERS                (0x00000011)  // UpperFilters (R/W)
#define SPDRP_LOWERFILTERS                (0x00000012)  // LowerFilters (R/W)
#define SPDRP_BUSTYPEGUID                 (0x00000013)  // BusTypeGUID (R)
#define SPDRP_LEGACYBUSTYPE               (0x00000014)  // LegacyBusType (R)
#define SPDRP_BUSNUMBER                   (0x00000015)  // BusNumber (R)
#define SPDRP_ENUMERATOR_NAME             (0x00000016)  // Enumerator Name (R)
#define SPDRP_SECURITY                    (0x00000017)  // Security (R/W, binary form)
#define SPDRP_SECURITY_SDS                (0x00000018)  // Security (W, SDS form)
#define SPDRP_DEVTYPE                     (0x00000019)  // Device Type (R/W)
#define SPDRP_EXCLUSIVE                   (0x0000001A)  // Device is exclusive-access (R/W)
#define SPDRP_CHARACTERISTICS             (0x0000001B)  // Device Characteristics (R/W)
#define SPDRP_ADDRESS                     (0x0000001C)  // Device Address (R)
#define SPDRP_UI_NUMBER_DESC_FORMAT       (0X0000001D)  // UiNumberDescFormat (R/W)
#define SPDRP_DEVICE_POWER_DATA           (0x0000001E)  // Device Power Data (R)
#define SPDRP_REMOVAL_POLICY              (0x0000001F)  // Removal Policy (R)
#define SPDRP_REMOVAL_POLICY_HW_DEFAULT   (0x00000020)  // Hardware Removal Policy (R)
#define SPDRP_REMOVAL_POLICY_OVERRIDE     (0x00000021)  // Removal Policy Override (RW)
#define SPDRP_INSTALL_STATE               (0x00000022)  // Device Install State (R)
#define SPDRP_LOCATION_PATHS              (0x00000023)  // Device Location Paths (R)

#define SPDRP_MAXIMUM_PROPERTY            (0x00000024)  // Upper bound on ordinals

//
// Class registry property codes
// (Codes marked as read-only (R) may only be used for
// SetupDiGetClassRegistryProperty)
//
// These values should cover the same set of registry properties
// as defined by the CM_CRP codes in cfgmgr32.h.
// they should also have a 1:1 correspondence with Device registers, where applicable
// but no overlap otherwise
//
#define SPCRP_SECURITY                    (0x00000017)  // Security (R/W, binary form)
#define SPCRP_SECURITY_SDS                (0x00000018)  // Security (W, SDS form)
#define SPCRP_DEVTYPE                     (0x00000019)  // Device Type (R/W)
#define SPCRP_EXCLUSIVE                   (0x0000001A)  // Device is exclusive-access (R/W)
#define SPCRP_CHARACTERISTICS             (0x0000001B)  // Device Characteristics (R/W)
#define SPCRP_MAXIMUM_PROPERTY            (0x0000001C)  // Upper bound on ordinals

但是,当您收集GPU信息时,您可能还想尝试OpenGL方法:

您可以收集支持的扩展和功能列表,还可以获得特定的GPU信息,例如管道数量,纹理单元,甚至是一些免费内存......

© www.soinside.com 2019 - 2024. All rights reserved.