获取设备管理器中显卡

#include <stdio.h>
#include <windows.h>
#include <Setupapi.h>
#include <devguid.h>
#include "tchar.h"

#pragma comment(lib, "SetupAPI.lib")
int main(int argc, char ** argv) 
{
  HDEVINFO deviceInfoSet;
  GUID *guidDev = (GUID*) &GUID_DEVCLASS_DISPLAY; 
  deviceInfoSet = SetupDiGetClassDevs(guidDev, NULL, NULL, DIGCF_PRESENT | DIGCF_PROFILE);
 TCHAR buffer [4000];
  DWORD buffersize =4000;
  int memberIndex = 0;
  while (true) 
  {
   SP_DEVINFO_DATA deviceInfoData;
   ZeroMemory(&deviceInfoData, sizeof(SP_DEVINFO_DATA));
   deviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
  if (SetupDiEnumDeviceInfo(deviceInfoSet, memberIndex, &deviceInfoData) == FALSE) 
  {
     if (GetLastError() == ERROR_NO_MORE_ITEMS) 
     {
       break;
     }
   }
   DWORD nSize=0 ;
   SetupDiGetDeviceInstanceId (deviceInfoSet, &deviceInfoData, buffer, sizeof(buffer), &nSize);
   buffer [nSize] ='\0';
   _tprintf (_T("%s\n"), buffer);
   BOOL res = SetupDiGetDeviceRegistryProperty(deviceInfoSet, &deviceInfoData,SPDRP_DEVICEDESC, 0, (BYTE*) buffer, sizeof(buffer), NULL);
   buffer [nSize] ='\0';
   _tprintf (_T("%s\n"), buffer);
   memberIndex++;
  }
  if (deviceInfoSet) 
  {
   SetupDiDestroyDeviceInfoList(deviceInfoSet);
  }
  return 0;
}
View Code

 http://www.codeproject.com/Articles/6597/CDeviceTree

http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/2555943e-0c69-4357-a85b-d6540bcaaf84

转载于:https://www.cnblogs.com/logitechlike/archive/2013/05/14/3077047.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值