user206705
user206705

Reputation:

Detecting available graphics memory on the windows platform using C++

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.

Upvotes: 4

Views: 1237

Answers (2)

paulsm4
paulsm4

Reputation: 121669

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

Upvotes: 1

graham.reeds
graham.reeds

Reputation: 16476

8mb. IIRC this is the maximum amount according to the AGP standard. All the extra memory on the gfx card was there to buffer the main memory so it didn't have to go across the bus.

I'd be surprised if the standard hadn't been revised.

If you have really old gfx cards to work with you can try looking at the Video Bios Extensions (VBE). That has a method for querying memory.

Upvotes: 0

Related Questions