问题描述
我正在尝试使用C#创建一个以太坊挖矿客户端,并且我需要检查系统是否具有AMD或NVIDIA.这是因为程序需要知道是否应该通过CUDA或OpenCL挖掘以太坊.
I'm trying to make an Ethereum mining client using C#, and I need to check whether the system has AMD or NVIDIA. This is because the program needs to know whether it should mine Ethereum via CUDA or OpenCL.
推荐答案
您需要使用System.Management命名空间(可以在引用/程序集下找到)
You need to use System.Management Namespace (You can find under references/Assemblies)
添加名称空间后,需要导航ManagementObject的所有属性,并导航propertydata的所有属性,直到在name属性上创建描述为止.
After adding namespace you need to navigate all properties of ManagementObject and navigate all properties of propertydata till founding description on name property.
我为控制台应用程序编写了此解决方案.您可以调整您的解决方案.
I wrote this solution for console app. You can adapt your solution.
尝试一下:
using System;
using System.Management;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
ManagementObjectSearcher searcher = new
ManagementObjectSearcher("SELECT * FROM Win32_DisplayConfiguration");
string gc = "";
foreach (ManagementObject obj in searcher.Get())
{
foreach (PropertyData prop in obj.Properties)
{
if (prop.Name == "Description")
{
gc = prop.Value.ToString().ToUpper();
if (gc.Contains("INTEL") == true)
{
Console.WriteLine("Your Graphic Card is Intel");
}
else if (gc.Contains("AMD") == true)
{
Console.WriteLine("Your Graphic Card is AMD");
}
else if (gc.Contains("NVIDIA") == true)
{
Console.WriteLine("Your Graphic Card is NVIDIA");
}
else
{
Console.WriteLine("Your Graphic Card cannot recognized.");
}
Console.ReadLine();
}
}
}
}
}
}
这篇关于如何检查系统在C#中是否具有AMD或NVIDIA?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!