Translate

Sunday, November 24, 2013

Enumerating physical display adapters on Windows.

 While working on RealBench v2 I had to enumerate the physical display adapters available on the user's system. There are several ways of doing this. I only found one that works the way I wanted it to work though.

 The most common suggested solution for this is EnumDisplayDevices(). The problem with this approach is that it returns one device per available output display port. So for my development system with reference design Geforce 680 2xSLI cards, it actually returned 4xGeforce 680 devices. You can filter devices that are connected to a screen but that doesn't help at all in enumerating physical display adapters for any user configuration.

 The second most suggested method is using DirectX's DXGI IDXGIFactory::EnumAdapters(). This is very easy to implement even for programmers who have never touched DirectX before BUT it still doesn't work as I needed it to work. As in the case of SLI/Crossfire it returns a single adapter instead of the amount of adapters present in the SLI/Crossfire array.

 The one I used is the Setup API method which includes SetupDiGetClassDevs(), SetupDiEnumDeviceInfo() and SetupDiGetDeviceRegistryProperty(). This one works exactly like I wanted it to. It will return exactly what I need it to. The actual physical display adapter devices. Here's sample code (it includes a couple of QStrings as I'm using Qt):

-------------------------------------------------------
    HDEVINFO deviceInfoSet;
    GUID *guidDev = (GUID*) &GUID_DEVCLASS_DISPLAY;
    deviceInfoSet = SetupDiGetClassDevs(guidDev, NULL, NULL, DIGCF_PRESENT | DIGCF_PROFILE);
    DWORD DataT;
    WCHAR *buffer[4000];
    DWORD buffersize = 4000;
    int memberIndex = 0;
    while (true)
    {
        SP_DEVINFO_DATA deviceInfoData;
        ZeroMemory(&deviceInfoData, sizeof(SP_DEVINFO_DATA));
        deviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
        if (SetupDiEnumDeviceInfo(deviceInfoSet, memberIndex, &deviceInfoData) == FALSE)
        {
            if (GetLastError() == ERROR_NO_MORE_ITEMS)
            {
                break;
            }
        }
        SetupDiGetDeviceRegistryProperty(deviceInfoSet, &deviceInfoData, SPDRP_DEVICEDESC, &DataT, (PBYTE)buffer, buffersize, NULL);
                  
        qDebug() << QString::fromWCharArray((WCHAR*)buffer);
        gpuInfo.append(QString::fromWCharArray((WCHAR*)buffer));

        memberIndex++;
    }
    if (deviceInfoSet)
    {
        SetupDiDestroyDeviceInfoList(deviceInfoSet);
    }
-------------------------------------------------------

There are a couple of other ways suggested. Namely, WMI and CCD API. Truth be told I never looked into these ways as Setup API did exactly what I wanted it to do and frankly I hate WMI. The CCD QueryDisplayConfig() function looks interesting and would be the next to try out if Setup API did not apply to my needs. :)

Sunday, November 17, 2013

RealBench v2 Public Beta release.

 I released earlier today the public beta of RealBench v2. The free benchmarking software I am developing for ASUS Republic of Gamers. There were a couple of issues due to my hastiness but nothing really serious. Hopefully it won't need lots of hours on the debugger..*wishful thinking*.

Link: RealBench-v2.0-Public-Beta!

ASUS OEM License Restorer

 So we had a lot of people, at the Republic of Gamers forums, with ASUS laptops that had lost their Windows recovery image or had simply wanted to install Windows from another iso, without the default vendor stuff. Yet they wanted to keep their ASUS OEM Windows license that is tied to their laptop or ASUS PC.

 So I cooked up this tool, with ASUS' permission, to restore the Win7 ASUS OEM license to ASUS laptops/PCs no matter how the user installed Windows.

Note: This is not a tool to activate Windows when you don't own a license. This will do absolutely nothing unless your ASUS laptop or PC has a valid ASUS OEM Windows license.


More about it and download link here: ASUS OEM License Restorer (Win7)