Video card detection under Windows system

Source: Internet
Author: User
Tags sprintf

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
  1. //-----------------------------------------------------------------------------
  2. File:DeviceID.cpp
  3. Copyright (c) 2006 ATI Technologies Inc. All rights reserved.
  4. //-----------------------------------------------------------------------------
  5. #include <windows.h>
  6. #include <stdio.h>
  7. int WINAPI WinMain (hinstance hthisins, hinstance hlastins, LPSTR lpszcmdline, int ncmdshow) { /c2>
  8. Char string[1024];
  9. Display_device Dev;
  10. DEV.CB = sizeof (display_device);
  11. int i = 0;
  12. while (enumdisplaydevices (NULL, I, &dev, 0)) {
  13. if (dev. StateFlags & Display_device_primary_device) {
  14. char *str = string + sprintf (string, "%s\n\n", Dev.  devicestring);
  15. char *vendorid = strstr (dev.  DeviceID, "Ven_");
  16. char *deviceid = strstr (dev.  DeviceID, "dev_");
  17. char *st = dev.  DeviceID;
  18. While (st = STRCHR (St, ' & ')) = NULL) {
  19. *st = ' + ';
  20. st++;
  21. }
  22. if (vendorid) str + = sprintf (str, "vendorid:0x%s\n", VendorID + 4);
  23. if (deviceID) str + = sprintf (str, "deviceid:0x%s\n", DeviceID + 4);
  24. MessageBox (NULL, String, "Device", MB_OK |  Mb_iconinformation);
  25. return 0;
  26. }
  27. i++;
  28. }
  29. MessageBox (NULL, "No primary device Found", "Error", MB_OK |  MB_ICONERROR);
  30. return-1;
  31. }

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.