首页 > 解决方案 > 如何在 C# 中找出屏幕连接到的显卡?

问题描述

我需要使用 C# 以编程方式找出屏幕连接到的图形卡。此信息在 DxDiag、speccy 甚至在 windows 高级显示设置视图中都可见: 规格

诊断诊断

视窗

但是我自己如何在 C# 中做到这一点?

标签: c#directx

解决方案


以下是@NielW 在C# 中检测哪个显卡驱动视频的代码

  ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_VideoController");
  foreach (ManagementObject mo in searcher.Get())
  {
    PropertyData currentBitsPerPixel = mo.Properties["CurrentBitsPerPixel"];
    PropertyData description = mo.Properties["Description"];
    if (currentBitsPerPixel != null && description != null)
    {
      if (currentBitsPerPixel.Value != null)
        System.Console.WriteLine(description.Value);
      }
    }
  }

链接中进行了长时间的讨论,因为他们在获取多个显卡的名称时遇到了问题。但是这段代码应该可以工作,它会显示所有可用显卡的名称。


推荐阅读