http://blog.csdn.net/cnjet/article/details/7827827
Because the graphics card manufacturers in the actual project will have special handling in some details, many programs also need to detect the video card and deal with the situation. How to detect video card information?
Reference 1:http://www.nvidia.com/object/device_ids.html
Reference 2:http://developer.amd.com/download/pc_vendor_id/pages/default.aspx
This is an example of a test given by two major independent graphics manufacturers.
Through summary, can be summed up as the following points:
1 through the EnumDisplayDevices function to enumerate the display device, to obtain the graphics card information;
2 The devicestring in the Display_device structure represents the graphics device model string;
The DeviceID in the 3 Display_device structure represents the specific model parameters of the graphics device, common such as VendorID (four bits after ven_) and device ID (dev_ four bits);
The relevant model information has been obtained. The specific ID value meaning needs to refer to the manufacturer's definition, for example:
NVIDIA's Vender ID is 0x10de;ati vendor ID is 0x1002;intel Vendor ID is 0x8086.
The following is an example of the ATI video card detection program source code.
[CPP]View Plaincopy
- //-----------------------------------------------------------------------------
- File:DeviceID.cpp
- Copyright (c) 2006 ATI Technologies Inc. All rights reserved.
- //-----------------------------------------------------------------------------
- #include <windows.h>
- #include <stdio.h>
- int WINAPI WinMain (hinstance hthisins, hinstance hlastins, LPSTR lpszcmdline, int ncmdshow) { /c2>
- Char string[1024];
- Display_device Dev;
- DEV.CB = sizeof (display_device);
- int i = 0;
- while (enumdisplaydevices (NULL, I, &dev, 0)) {
- if (dev. StateFlags & Display_device_primary_device) {
- char *str = string + sprintf (string, "%s\n\n", Dev. devicestring);
- char *vendorid = strstr (dev. DeviceID, "Ven_");
- char *deviceid = strstr (dev. DeviceID, "dev_");
- char *st = dev. DeviceID;
- While (st = STRCHR (St, ' & ')) = NULL) {
- *st = ' + ';
- st++;
- }
- if (vendorid) str + = sprintf (str, "vendorid:0x%s\n", VendorID + 4);
- if (deviceID) str + = sprintf (str, "deviceid:0x%s\n", DeviceID + 4);
- MessageBox (NULL, String, "Device", MB_OK | Mb_iconinformation);
- return 0;
- }
- i++;
- }
- MessageBox (NULL, "No primary device Found", "Error", MB_OK | MB_ICONERROR);
- return-1;
- }
Source
----------------------------------
//-----------------------------------------------------------------------------
File:DeviceID.cpp
Copyright (c) 2006 ATI Technologies Inc. All rights reserved.
//-----------------------------------------------------------------------------
#include <windows.h>
#include <stdio.h>
int WINAPI WinMain (hinstance hthisins, hinstance hlastins, LPSTR lpszcmdline, int ncmdshow) {
Char string[1024];
Display_device Dev;
DEV.CB = sizeof (Display_device);
int i = 0;
while (EnumDisplayDevices (NULL, I, &dev, 0)) {
if (Dev. StateFlags & Display_device_primary_device) {
Char *str = string + sprintf (String, "%s\n\n", Dev. devicestring);
Char *vendorid = strstr (dev. DeviceID, "Ven_");
Char *deviceid = strstr (dev. DeviceID, "dev_");
char *st = dev. DeviceID;
while (st = STRCHR (St, ' & ')) = NULL) {
*st = ' + ';
st++;
}
if (vendorid) str + = sprintf (str, "vendorid:0x%s\n", VendorID + 4);
if (deviceID) str + = sprintf (str, "deviceid:0x%s\n", DeviceID + 4);
MessageBox (NULL, String, "Device", MB_OK | Mb_iconinformation);
return 0;
}
i++;
}
MessageBox (NULL, "No primary device Found", "Error", MB_OK | MB_ICONERROR);
return-1;
}
Video card detection under Windows system