BETA Release OglaClient Beta 100416

dumbo2007

Crazy about real time sims
Joined
Nov 29, 2009
Messages
675
Reaction score
0
Points
0
Location
India
Right yeah....I forgot about the crash on Radeon cards.

By the way....there was some code available in MSDN on how to get the video card manufacturer using Windows Managed Instrumentation :

Code:
#define _WIN32_DCOM
#include <iostream>
using namespace std;
#include <comdef.h>
#include <Wbemidl.h>

# pragma comment(lib, "wbemuuid.lib")

int ShowVideoControllers()
{
    HRESULT hr;
    hr = CoInitializeEx(0, COINIT_MULTITHREADED); 

    if (FAILED(hr)){
        cout << "Failed to initialize COM library. Error code = 0x" << hex << hr << endl; 
        return hr;
    }

    hr =  CoInitializeSecurity(
        NULL,                        // Security descriptor    
        -1,                          // COM negotiates authentication service
        NULL,                        // Authentication services
        NULL,                         // Reserved
        RPC_C_AUTHN_LEVEL_DEFAULT,     // Default authentication level for proxies
        RPC_C_IMP_LEVEL_IMPERSONATE, // Default Impersonation level for proxies
        NULL,                        // Authentication info
        EOAC_NONE,                   // Additional capabilities of the client or server
        NULL);                       // Reserved


    if (FAILED(hr)){
        cout << "Failed to initialize security. Error code = 0x" << hex << hr << endl;
        CoUninitialize();
        return hr;                  // Program has failed.
    }


    IWbemLocator *pLoc = 0;

    hr = CoCreateInstance(CLSID_WbemLocator, 0, 
        CLSCTX_INPROC_SERVER, IID_IWbemLocator, (LPVOID *) &pLoc);

    if (FAILED(hr)){
        cout << "Failed to create IWbemLocator object. Err code = 0x" << hex << hr << endl;
        CoUninitialize();
        return hr;     // Program has failed.
    }

    IWbemServices *pSvc = 0;

    // Connect to the root\cimv2 namespace with the
    // current user and obtain pointer pSvc
    // to make IWbemServices calls.

    hr = pLoc->ConnectServer(        
        _bstr_t(L"ROOT\\CIMV2"), // WMI namespace
        NULL,                    // User name
        NULL,                    // User password
        0,                       // Locale
        NULL,                    // Security flags                 
        0,                       // Authority       
        0,                       // Context object
        &pSvc                    // IWbemServices proxy
        );                              

    if (FAILED(hr)){
        cout << "Could not connect. Error code = 0x" << hex << hr << endl;
        pLoc->Release();     
        CoUninitialize();
        return 1;                // Program has failed.
    }

    cout << "Connected to ROOT\\CIMV2 WMI namespace" << endl;

    // Set the IWbemServices proxy so that impersonation
    // of the user (client) occurs.
    hr = CoSetProxyBlanket(       
        pSvc,                         // the proxy to set
        RPC_C_AUTHN_WINNT,            // authentication service
        RPC_C_AUTHZ_NONE,             // authorization service
        NULL,                         // Server principal name
        RPC_C_AUTHN_LEVEL_CALL,       // authentication level
        RPC_C_IMP_LEVEL_IMPERSONATE,  // impersonation level
        NULL,                         // client identity 
        EOAC_NONE                     // proxy capabilities     
        );

    if (FAILED(hr)){
        cout << "Could not set proxy blanket. Error code = 0x" << hex << hr << endl;
        pSvc->Release();
        pLoc->Release();     
        CoUninitialize();
        return 1;               // Program has failed.
    }


    // Use the IWbemServices pointer to make requests of WMI. 
    // Make requests here:
    IEnumWbemClassObject* pEnumerator = NULL;    
    hr = pSvc->ExecQuery(
        bstr_t("WQL"), 
        bstr_t("SELECT * FROM Win32_VideoController"),
        WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, 
        NULL,
        &pEnumerator);

    if (FAILED(hr)){
        cout << "Query for video card failed. " << "Error code = 0x" << hex << hr << endl;
        pSvc->Release();
        pLoc->Release();     
        CoUninitialize();
        return 1;               // Program has failed.
    }
    else{ 
        IWbemClassObject *pclsObj;
        ULONG uReturn = 0;

        while (pEnumerator){

            hr = pEnumerator->Next(WBEM_INFINITE, 1, 
                &pclsObj, &uReturn);

            if(0 == uReturn)
                break;

            VARIANT vtProp;

            // Get the value of the Name property
            hr = pclsObj->Get(L"Name", 0, &vtProp, 0, 0);
            wcout << "Video Card Name : " << vtProp.bstrVal << endl;
            VariantClear(&vtProp);
        }         
    }


    // Cleanup !!
    // pSvc was declared as IWbemServices *pSvc;
    // pLoc was declared as IWbemLocator *pLoc;
    pSvc->Release();
    pLoc->Release();     
    CoUninitialize();

    return 0;
}

int main(int argc, char **argv)
{
    int i;

    if(ShowVideoControllers() > 0){
        cout << "Something went wrong";
    }
    else
        cin >> i;  //to pause program - simplest way :)
}

Should compile with VC++
 
Top