【问题标题】:How to check if the system has AMD or NVIDIA in C#?如何在 C# 中检查系统是否有 AMD 或 NVIDIA?
【发布时间】:2018-08-27 03:09:00
【问题描述】:

我正在尝试使用 C# 制作以太坊挖矿客户端,我需要检查系统是否具有 AMD 或 NVIDIA。这是因为程序需要知道是应该通过 CUDA 还是 OpenCL 挖掘以太坊。

【问题讨论】:

    标签: c# cuda opencl ethereum mining


    【解决方案1】:

    你需要使用 System.Management 命名空间(你可以在references/Assemblies下找到)

    添加命名空间后,您需要导航 ManagementObject 的所有属性并导航 propertydata 的所有属性,直到在 name 属性上创建描述。

    我为控制台应用程序编写了这个解决方案。您可以调整您的解决方案。

    试试这个:

     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();
                    }
                }
            }
        }
    }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-16
      • 2011-01-18
      • 2010-09-16
      相关资源
      最近更新 更多