我的C#应用程序位于具有Intel主板和图形芯片组的嵌入式盒子上.ATI显卡放在PCI Express上.通常显卡驱动视频,但如果ATI卡出现故障,则视频会从图形芯片组中传出.
我必须检测ATI显卡的故障以进行诊断.
有关如何执行此操作的任何想法/示例代码.
在此先感谢Raju
Tow*_*own 19
这应该有希望让你开始.
添加引用System.Management,然后您可以这样做:
ManagementObjectSearcher searcher
= new ManagementObjectSearcher("SELECT * FROM Win32_DisplayConfiguration");
string graphicsCard = string.Empty;
foreach (ManagementObject mo in searcher.Get())
{
foreach (PropertyData property in mo.Properties)
{
if (property.Name == "Description")
{
graphicsCard = property.Value.ToString();
}
}
}
Run Code Online (Sandbox Code Playgroud)
就我而言,graphicsCard等于
NVIDIA GeForce 8400 GS(微软公司 - WDDM v1.1)
我不是所选答案如何仅返回第一个视频控制器的粉丝.此外,没有必要循环所有属性.得到你需要的.如果CurrentBitsPerPixel不为null,那么您正在查看其中一个活动控制器.我正在使用@bairog建议的Win32_VideoController,而不是弃用的Win32_DisplayConfiguration.
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);
}
}
Run Code Online (Sandbox Code Playgroud)
我的机器有3个视频控制器.第一个不活跃(ShoreTel).第二个是活动的,但不是视频卡(Desktop Authority).第三个是我的NVidia.此代码将打印出DA控制器和NVidia控制器.
| 归档时间: |
|
| 查看次数: |
17110 次 |
| 最近记录: |