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.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You need to use System.Management Namespace (You can find under references/Assemblies)
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.
Try this:
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();
}
}
}
}
}
}