none
How to retrieve video card's info?

    Question

  • Hi,

    In my app, I want to retrieve some information about the video card's description(such as the type name of it) at run time. Do you have any idea about it?

    Thanks

    Thursday, July 26, 2007 2:08 AM

Answers

All replies

  • You can use WMI's Video card remated classes, I dont exactly understand what you mean by 'type name' but surely you can browse throw the class properties to see if anything fits.

     

    Win32 Classes (Windows) , Win32_DisplayControllerConfiguration (Windows)

     

    WMI C++ Application Examples (Windows)

     

    Making WMI Queries In C++ - The Code Project - System

    Thursday, July 26, 2007 7:34 AM
  • Hi,

    Thanks for your reply and sorry for my poor english. What I mean by 'type name' is, for example, the video card on my computer have a description of 'NVIDIA GeForce 7300 GT'. I just need some methods for my app to detect that infomation on the target machine at run time, and display it. Hope this will make things more clear.

     

    Thursday, July 26, 2007 7:52 AM
  • The the Win32_DisplayControllerConfiguration.Caption is what you need.

    Thursday, July 26, 2007 1:12 PM
  • Hi,

    Thank you. I have done it according to the sample code you provided, as such:

     

    Code Snippet
    #define _WIN32_DCOM
    #include <iostream>
    using namespace std;
    #include <comdef.h>
    #include <Wbemidl.h>
    # pragma comment(lib, "wbemuuid.lib")

     

    int _tmain(int argc, _TCHAR* argv[])
    {
     HRESULT hres;
        hres =  CoInitializeEx(0, COINIT_MULTITHREADED);
        if (FAILED(hres)) return 0;
        hres =  CoInitializeSecurity(NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_DEFAULT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL);
        if (FAILED(hres)){CoUninitialize(); return 0;}
        IWbemLocator *pLoc = NULL;
        hres = CoCreateInstance(CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER, IID_IWbemLocator, (LPVOID *) &pLoc);
        if (FAILED(hres)){ CoUninitialize(); return 0;}
        IWbemServices *pSvc = NULL;
        hres = pLoc->ConnectServer( _bstr_t(L"root\\CIMV2"), NULL, NULL, 0, NULL, 0, 0, &pSvc);
        if (FAILED(hres)){ pLoc->Release(); CoUninitialize(); return 0;}
        hres = CoSetProxyBlanket(pSvc, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL, RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE);
        if (FAILED(hres)){pSvc->Release(); pLoc->Release(); CoUninitialize(); return 0;}
        IEnumWbemClassObject* pEnumerator = NULL;
        hres = pSvc->ExecQuery(bstr_t("WQL"),
            bstr_t("SELECT * FROM Win32_VideoController"),
            WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, NULL, &pEnumerator);
     if (FAILED(hres)){pSvc->Release(); pLoc->Release(); CoUninitialize(); return 0;}
        IWbemClassObject *pclsObj;
        ULONG uReturn = 0;
        while(pEnumerator)
        {
            HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn);
            if(0 == uReturn)break;
            VARIANT vtProp;
            hr = pclsObj->Get(L"Caption", 0, &vtProp, 0, 0);
      wcout << " OS Name : " << vtProp.bstrVal << endl;
            VariantClear(&vtProp);
        }
        pSvc->Release();
        pLoc->Release();
        pEnumerator->Release();
        pclsObj->Release();
        CoUninitialize();

     return 0;
    }

     

     

     

     

    Thursday, July 26, 2007 1:32 PM