How to get graphics card memory amount

How could we get the information about total graphics card memory amount? I know it could be found through WMI, does somebody have any piece of code about this? Its not directly related to OpenGL, but I guess many developers must be interested in it. DirectX has a function for getting this amount, but I don’t want to use DX.

Nvidia has a framework and a demo for this:……dSystemInfo.pdf

The good news is that you don’t need to create a device or otherwise engage D3D. File wise, I’ve found that all you really need is objbase.h and dxdiag.h, and a link with ole32.lib and dxguid.lib.


If you happen to be on XP or later and you’re using .NET, WMI gets really, really simple:

using System.Management;

public class TestWMI
    public static void DumpVideoControllerInfo()
        ManagementClass c = new ManagementClass("Win32_VideoController");
        foreach (ManagementObject o in c.GetInstances())
            Console.WriteLine("GPU: {0} ({1} bytes vram)", o["VideoProcessor"], o["AdapterRam"]);

I haven’t fooled with this in C++, but as I understand it, WMI previously was considerably more complicated.

If you’re a glutton for punishment, here’s some sample code from the MSDN:…on_examples.asp

Thanks, I’ll look on DX code. I use C++, but prefer easy way :slight_smile: . Maybe some day somebody will release WMI tutorial.

did anyone make a cross platform class/lib that wraps what’s needed for every platform ? (wmi/dx for windows, etc…)

For kicks, I just tested the first example from the MSDN, and it works! All you need to do is substitute “Win32_VideoController” for “Win32_OperatingSystem”, for example, then query the appropriate properties in the enumeration loop, like “Name” or “AdapterRam.”

Still, I like the IDxDiag* interfaces better, since they do a good job of hiding the OS flavors, caveats and gotchas; and being geared specifically for retrieving the more interesting multimedia properties, they are potentially more pleasant to work with.

Yes, it works with WMI, the example on page…al_computer.asp

replace it by Win32_VideoController like you mentioned and replace two lines:

hr = pclsObj->Get(L"Name", 0, &vtProp, 0, 0);
wcout << " OS Name : " << vtProp.bstrVal << endl;


hr = pclsObj->Get(L"AdapterRAM", 0, &vtProp, 0,0);
printf ("
%d", vtProp.uintVal);

to directly get the adapter RAM.

If you want, and in case you didn’t know, you can get a comprehensive list of classes and their properties by searching for “win32 classes” in the MSDN.

Here’s the main list:

And here’s the video controller:…ocontroller.asp

Yes, I found the info about “AdapterRAM” there.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.