Search code examples
windowsregistrydirectxdirectx-9

Registry version wrong


I want to read the DirectX version from Registry.

I found the value at HKLM\Software\Microsoft\DirectX under the value Version.

My problem: Refering to Hey Scripting Guy! my version "4.09.00.0904" is 9.0c, but dxdiag shows DirectX 11.

How to find the right version? Or is there probably a way to solve this without the registry?

EDIT: I'm using Windows 7 Professional x86


Solution

  • You can't detect any version above DirectX 9 from the registry. It's simply not stored in there.

    For versions 10 and above, you should use the COM interface to DXDiag.

    1. Instantiate a DXDiagProvider (CoCreateInstance( CLSID_DxDiagProvider, ... IID_IDxDiagProvider, ... )
    2. Initialize it (pDxDiagProvider->Initialize)
    3. Open the root container (pDxDiagProvider->GetRootContainer)
    4. Open the child container DxDiag_SystemInfo (rootContainer->GetChildContainer(L"DxDiag_SystemInfo", ...)
    5. Read the variant (VT_UI4) properties dwDirectXVersionMajor and dwDirectXVersionMajor (systemInfo->GetProp( ... ))
    6. If relevant, read the VT_BSTR property szDirectXVersionLetter as well.

    Inconvenient? Very. Write once, wrap in a utility function, never look back. Or copy-paste one of the common implementations.