问题
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();
}
}
}
}
}
}
来源:https://stackoverflow.com/questions/49348026/how-to-check-if-the-system-has-amd-or-nvidia-in-c