在编程时,是否有API可以获取显卡的主频、显示器的对比度,或者其他什么方法可以实现同样的功能(除了借助于其他软件),欢迎有进行过相关编程的达人进行解答 (∩_∩)o...

解决方案 »

  1.   

     VC下获得显卡信息主要通过Direct 3D的几个函数完成的,包括Direct3DCreate9(),GetAdapterCount(),GetAdapterIdentifier().   其中GetAdapterIdentifier()的描述如下
    IDirect3D9::GetAdapterIdentifierDescribes the physical display adapters present in the system when the IDirect3D9 interface was instantiated.HRESULT GetAdapterIdentifier(
      UINT Adapter,
      DWORD Flags,
      D3DADAPTER_IDENTIFIER9 * pIdentifier
    );用D3DADAPTER_IDENTIFIER9返回显卡信息,下面是D3DADAPTER_IDENTIFIER9的定义typedef struct D3DADAPTER_IDENTIFIER9 {
        char Driver[MAX_DEVICE_IDENTIFIER_STRING];
        char Description[MAX_DEVICE_IDENTIFIER_STRING];
        char DeviceName[32];
        LARGE_INTEGER DriverVersion;
        DWORD DriverVersionLowPart;
        DWORD DriverVersionHighPart;
        DWORD VendorId;
        DWORD DeviceId;
        DWORD SubSysId;
        DWORD Revision;
        GUID DeviceIdentifier;
        DWORD WHQLLevel;
    } D3DADAPTER_IDENTIFIER9, *LPD3DADAPTER_IDENTIFIER9;//代码LPDIRECT3D9 pD3D=NULL;
    pD3D=Direct3DCreate9(D3D_SDK_VERSION);//创建Direct 3D对象
    DWORD m_dwNumAdapters=pD3D-> GetAdapterCount();//获得显卡数量
    for(UINT iAdapter=0;iAdapter<m_dwNumAdapters;iAdapter++) 

          D3DADAPTER_IDENTIFIER9 di;
          pD3D-> GetAdapterIdentifier(iAdapter,0,&di);//获得显卡信息
          char  szBuf[256]; 
          sprintf(szBuf,"%s",di.Description);//  
          MessageBox(szBuf);
    }
      

  2.   

    // This sample is a program which show the information ,such as description,
    // provider and version of each  pci device:
    //retrieve a set of all devices on the Peripheral Component Interconnect (PCI) 
    //bus. 
        HDEVINFO hPciDevInfo = SetupDiGetClassDevs(NULL,REGSTR_KEY_PCIENUM,0,
    DIGCF_PRESENT | DIGCF_ALLCLASSES );
       if (hPciDevInfo == INVALID_HANDLE_VALUE)   return ;
    // Show all related device in the PCI set
        DisplayDriverDsp(hPciDevInfo);
    void CTestDlg::DisplayDriverDsp(HDEVINFO hDevInfo)
    {
        SP_DEVINFO_DATA DeviceInfoData;
    DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
    TCHAR buffer[MAX_PATH];
    ZeroMemory(buffer, MAX_PATH);
    HKEY hCurKey;
    CString strConstKey;
    HKEY hRootKey = HKEY_LOCAL_MACHINE;
    if (bIsNt)
    strConstKey = "SYSTEM\\CurrentControlSet\\Control\\Class\\";
    else
    strConstKey = "SYSTEM\\CurrentControlSet\\Services\\Class\\";
    /*DWORD dwI, dwValueType;
    TCHAR szValueName[MAX_PATH];
    TCHAR szValueData[MAX_PATH];
    ZeroMemory(szValueName, MAX_PATH);
    ZeroMemory(szValueData, MAX_PATH);
    DWORD dwVNameSize, dwVDataSize;
    dwVNameSize = MAX_PATH;
    dwVDataSize = MAX_PATH;*/
        for (DWORD i=0;SetupDiEnumDeviceInfo(hDevInfo,i,&DeviceInfoData);i++)
        {
            SetupDiGetDeviceRegistryProperty(hDevInfo, &DeviceInfoData, 
    SPDRP_DRIVER, NULL, (PBYTE)buffer, MAX_PATH, NULL);
    CString strKey = strConstKey;
    strKey += buffer;
    if (ERROR_SUCCESS != ::RegOpenKey(hRootKey, (LPCSTR)strKey, &hCurKey))
    {
    TRACE("%d", GetLastError());
    return;
    }
             // Get the driver description
    DWORD dwType = REG_SZ;
    if (ERROR_SUCCESS != ::RegQueryValueEx(hCurKey, "DriverDesc", NULL, 
    &dwType, (LPBYTE)szValueData, &dwVDataSize))
    return;
             // Get provider name
    if (ERROR_SUCCESS != ::RegQueryValueEx(hCurKey, "ProviderName", NULL, &dwType, (LPBYTE)szValueData, &dwVDataSize))
    return;
             // Retrieve version:
    if (ERROR_SUCCESS != ::RegQueryValueEx(hCurKey, "Ver", NULL, &dwType, (LPBYTE)szValueData, &dwVDataSize))
    return;
    }
      

  3.   

    int nHeightMilli = dc.GetDeviceCaps(VERTSIZE); 高度是多少像素
    int nHeightPixel = dc.GetDeviceCaps(VERTRES);长度是多少像素