How to retrieve info about videocard.

Started by
8 comments, last by chronozphere 15 years, 11 months ago
Hi game-developers I would like to know whether there is a way of retrieving data about your videocard programmaticly. I would be interested in the following information: Vendor, Name, Version, Ammount of memory and maybe things like GPU speeds, mem speeds or something like that. I know it's possible to retrieve this info, because programs like Everest can do this. So, can anyone tell me how to do this? Thanx a bunch! ;)
Advertisement
Vendor, name and driver version is possible with D3D (IDirect3D9::GetAdapterIdentifier). I believe you can get the same info from OpenGL. Anything more than that and you'll probably have to do some horrible driver specific hacks.
I think, amount of memory and GPU speed and thinks like that is not receivable via the direct3d enumeration structures and functions.
I have never tried it, but you could also think about performance tools form nvidia and amd?!

Check out the directX caps viewer to see what is receivable with the enum functionality.

Alex
I believe DirectShow can get total video memory, and D3D can report available texture memory.

When I write a log file I always output general PC info like CPU, OS, RAM, video card, audio card etc. All this info is available by using WMI. It's even easier to access this info in .NET Framework using System.Management.
Thanx for the quick replies. ;)

Does anyone know how to do this with OpenGL?
And what exactly is WMI?

Thanks again. :D
WMI is Windows Management Instrumentation which can be used to query hardware info.

Here is an example using C# to get information about the video card.

ManagementObjectSearcher query = new ManagementObjectSearcher("SELECT * FROM Win32_VideoController");foreach (ManagementObject obj in query.Get()){	WriteEntry("Video Card: " + obj["Name"].ToString());	WriteEntry("Video Driver: " + obj["DriverVersion"].ToString());	if (obj["AdapterRAM"] != null)	{		double videoRAM = double.Parse(obj["AdapterRAM"].ToString()) / 1024 / 1024;		WriteEntry("Video RAM: " + videoRAM + " MB");	}}
This prints at least some information about the display adapter via OpenGL (from wglinfo.c):
printf("OpenGL vendor string: %s\n", glGetString(GL_VENDOR));printf("OpenGL renderer string: %s\n", glGetString(GL_RENDERER));printf("OpenGL version string: %s\n", glGetString(GL_VERSION));

On my laptop it prints:
OpenGL vendor string: S3 GraphicsOpenGL renderer string: VIA/S3G UniChrome IGP/MMX/SSEOpenGL version string: 1.2
@Headkaze: Thanx for your info. However, i don't use "managed code", so i need some other snippet... nevertheless thanx. ;)

@SnotBob: Thank you, very usefull!
Here is a page that shows C++ code to get Video card info using WMI

http://www.scodz.com/ViewProgram.php?link=867

#include "comutil.h"#include "Wbemcli.h"#include "Wbemidl.h"// create edit controls to display information// add this code button event or as ur wishHRESULT hr;hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);IWbemLocator *pIWbemLocator = NULL;hr = CoCreateInstance(__uuidof(WbemLocator), NULL,	CLSCTX_INPROC_SERVER, __uuidof(IWbemLocator),	(LPVOID *) &pIWbemLocator);BSTR bstrServer = SysAllocString(L"\\\\.\\root\\cimv2");IWbemServices *pIWbemServices;hr = pIWbemLocator->ConnectServer(bstrServer, NULL, NULL, 0L, 0L, NULL,	NULL, &pIWbemServices);hr = CoSetProxyBlanket(pIWbemServices, RPC_C_AUTHN_WINNT,	RPC_C_AUTHZ_NONE, NULL, RPC_C_AUTHN_LEVEL_CALL,	RPC_C_IMP_LEVEL_IMPERSONATE, NULL,	EOAC_DEFAULT);BSTR bstrWQL  = SysAllocString(L"WQL");BSTR bstrPath = SysAllocString(L"select * from Win32_VideoController");IEnumWbemClassObject* pEnum;hr = pIWbemServices->ExecQuery(bstrWQL, bstrPath, WBEM_FLAG_FORWARD_ONLY, NULL, &pEnum);IWbemClassObject* pObj = NULL;ULONG uReturned;VARIANT var;hr = pEnum->Next(WBEM_INFINITE, 1, &pObj, &uReturned );if (uReturned){	hr = pObj->Get(L"AdapterRAM", 0, &var, NULL, NULL);	if(SUCCEEDED(hr))	{		char str[MAX_PATH];		sprintf(str,"Video Memory %ld",(var.lVal/(1024*1024)));		m_vidMemoryTxt.SetWindowText(str);	}	hr = pObj->Get(L"ConfigManagerErrorCode", 0, &var, NULL, NULL);	if(SUCCEEDED(hr))	{		char str[MAX_PATH];		sprintf(str,"ConfigManagerErrorCode %ld",var.lVal);		switch (var.lVal)		{		case 0:			m_ConfigManagerErrorCodeTxt.SetWindowText("This device is working properly");			break;		case 1:			m_ConfigManagerErrorCodeTxt.SetWindowText("This device is not configured correctly");			break;		case 2:			m_ConfigManagerErrorCodeTxt.SetWindowText("Windows cannot load the driver for this device.");			break;		case 3:			m_ConfigManagerErrorCodeTxt.SetWindowText("The driver for this device might be corrupted, or your system may be running low on memory or other resources.");			break;		case 4:			m_ConfigManagerErrorCodeTxt.SetWindowText("This device is not working properly. One of its drivers or your registry might be corrupted.");			break;		case 5:			m_ConfigManagerErrorCodeTxt.SetWindowText("The driver for this device needs a resource that Windows cannot manage.");			break;		case 6:			m_ConfigManagerErrorCodeTxt.SetWindowText("The boot configuration for this device conflicts with other devices.");			break;		case 7:			m_ConfigManagerErrorCodeTxt.SetWindowText("Cannot filter.");			break;		case 8:			m_ConfigManagerErrorCodeTxt.SetWindowText("The driver loader for the device is missing");			break;		case 11:			m_ConfigManagerErrorCodeTxt.SetWindowText("This device failed.");			break;		case 12:			m_ConfigManagerErrorCodeTxt.SetWindowText("This device cannot find enough free resources that it can use.");			break;		case 14:			m_ConfigManagerErrorCodeTxt.SetWindowText("This device cannot work properly until you restart your computer.");			break;		case 18:			m_ConfigManagerErrorCodeTxt.SetWindowText("Reinstall the drivers for this device.");			break;		case 20:			m_ConfigManagerErrorCodeTxt.SetWindowText("Your registry might be corrupted.");			break;		}	}	// *********** driver name	hr = pObj->Get(L"Name", 0, &var, NULL, NULL);	if(SUCCEEDED(hr))	{		char sString[256];		WideCharToMultiByte(CP_ACP, 0, var.bstrVal, -1, sString,		sizeof(sString), NULL, NULL);		m_nameTxt.SetWindowText(sString);	}	hr = pObj->Get(L"DeviceID", 0, &var, NULL, NULL);	if(SUCCEEDED(hr))	{		char sString[256];		WideCharToMultiByte(CP_ACP, 0, var.bstrVal, -1, sString,		sizeof(sString), NULL, NULL);		m_deviceIdTxt.SetWindowText(sString);	}	hr = pObj->Get(L"DriverVersion", 0, &var, NULL, NULL);	if(SUCCEEDED(hr))	{		char sString[256];		WideCharToMultiByte(CP_ACP, 0, var.bstrVal, -1, sString,		sizeof(sString), NULL, NULL);		m_VersionTxt.SetWindowText(sString);	}		hr = pObj->Get(L"DriverDate", 0, &var, NULL, NULL);	if(SUCCEEDED(hr))	{		char str[MAX_PATH];		SYSTEMTIME lpSystemTime;		memset( &lpSystemTime, 0, sizeof( SYSTEMTIME ) );		char char_string[100]="";		//BSTR dateStr = var.bstrVal;		//_bstr_t bstrIntermediate(*dateStr);    // convert to _bstr_t		//_stprintf(char_string, _T("%s"), (LPCTSTR)bstrIntermediate);		//char* lpszText2 = _com_util::ConvertBSTRToString(dateStr);		//	int res= VariantTimeToSystemTime(var.bstrVal, & lpSystemTime    ); 				/*DWORD err =::GetLastError();		sprintf(str,"%ld // %ld // %ld",lpSystemTime.wDay,lpSystemTime.wMonth,lpSystemTime.wYear);		m_InstalldateTxt.SetWindowText( str);*/	}		//VideoProcessor	hr = pObj->Get(L"VideoProcessor", 0, &var, NULL, NULL);	if(SUCCEEDED(hr))	{		char sString[256];		WideCharToMultiByte(CP_ACP, 0, var.bstrVal, -1, sString,			sizeof(sString), NULL, NULL);		m_InstalldateTxt.SetWindowText( sString);				}		hr = pObj->Get(L"VideoModeDescription", 0, &var, NULL, NULL);	if(SUCCEEDED(hr))	{		char sString[256];		WideCharToMultiByte(CP_ACP, 0, var.bstrVal, -1, sString,			sizeof(sString), NULL, NULL);		m_videodcrTxt.SetWindowText(sString);				}		hr = pObj->Get(L"AdapterDACType", 0, &var, NULL, NULL);	if(SUCCEEDED(hr))	{		char sString[256];		WideCharToMultiByte(CP_ACP, 0, var.bstrVal, -1, sString,			sizeof(sString), NULL, NULL);		m_DacTypeTxt.SetWindowText(sString);		}		hr = pObj->Get(L"VideoArchitecture", 0, &var, NULL, NULL);	if(SUCCEEDED(hr))	{		char str[MAX_PATH];		sprintf(str,"Video Memory %ld",(var.lVal));		switch(var.lVal)		{		case 5:			m_arch.SetWindowText("VGA");			break;		case 6:			m_arch.SetWindowText("SVGA");			break;		case 7:			m_arch.SetWindowText("MDA");			break;		case 10:			m_arch.SetWindowText("8514A");			break;		case 11:			m_arch.SetWindowText("XGA");			break;		case 12:			m_arch.SetWindowText("Linear Frame Buffer");			break;		}		//m_DacTypeTxt.SetWindowText(sString);		}}// ***********pEnum->Release();SysFreeString(bstrPath);SysFreeString(bstrWQL);pIWbemServices->Release();SysFreeString(bstrServer);CoUninitialize();


[Edited by - Headkaze on May 21, 2008 3:33:01 PM]
Thanks for your great help... will look into it. ;)

This topic is closed to new replies.

Advertisement