Ways to Get Video Memory
There are several ways to get the video memory size on a system. This sample demonstrates 5 methods. The first 4 are available on Windows XP or later, while DXGI is only available on Windows Vista or later.
GetVideoMemoryViaDirectDraw: This method queries the DirectDraw 7 interfaces for the amount of available video memory. On a discrete video card, this is often close to the amount of dedicated video memory and usually does not take into account the amount of shared system memory.
GetVideoMemoryViaWMI: This method queries the Windows Management Instrumentation (WMI) interfaces to determine the amount of video memory. On a discrete video card, this is often close to the amount of dedicated video memory and usually does not take into account the amount of shared system memory.
GetVideoMemoryViaDxDiag: DxDiag internally uses both DirectDraw 7 and WMI and returns the rounded WMI value if WMI is available. Otherwise, it returns a rounded DirectDraw 7 value.
GetVideoMemoryViaD3D9: This method queries D3D9 for the amount of available texture memory. On Windows Vista, this number is typically the dedicated video memory plus the shared system memory minus the amount of memory in use by textures and render targets.
GetVideoMemoryViaDXGI: DXGI is only available on Windows Vista or later. This method returns the amount of dedicated video memory, the amount of dedicated system memory, and the amount of shared system memory. DXGI is more reflective of the true system configuration than the previous 4 methods.
Best Practices
On Windows Vista or later, DXGI should always be used to query the available video memory.