I’d like to be able to detect how much graphics memory is available. I’ve written a C++ project that uses DirectShow.
Some ancient gfx cards can’t do video properly and fall back to four colour mode. If I try to allocate more than one video window, the program just crashes on these machines without warning.
This is less than elegant, and I’d like to detect available graphics memory ahead of time, so I can determine if the program has enough gfx mem to run.
A really sneaky way that should work on XP and lower is to read the registry:
For example, I access \HKLM\Hardware\Devicemap\Video and get a GUID:
{3468769C-3D6B-4BB1-85B6-7B5AE7F4E8F8}
Then I access \HKLM\CCS\Control\Video, and read “HardwareInformation.MemorySize” for that device:
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Video{3468769C-3D6B-4BB1-85B6-7B5AE7F4E8F8}
A much better approach (the recommended approach, in fact) is to use WMI:
GetVideoMemoryViaWMI