Retrieving graphics/sound card information on Windows

走远了吗. 提交于 2019-12-11 04:24:34

问题


I'm working on a bug reporting tool for my application, and I'd like to attach hardware information to bug reports to make pinpointing certain problems easier. Does anyone know of any Win32 API functions to query the OS for information on the graphics and sound cards?

Thanks, Rob


回答1:


If your willing to dig into WMI the following should get you started.

using System;
using System.Management;

namespace WMIData
{
    class Program
    {
        static void Main(string[] args)
        {
            SelectQuery querySound = new SelectQuery("Win32_SoundDevice");
            ManagementObjectSearcher searcherSound = new ManagementObjectSearcher(querySound);
            foreach (ManagementObject sound in searcherSound.Get())
            {
                Console.WriteLine("Sound device: {0}", sound["Name"]);
            }

            SelectQuery queryVideo = new SelectQuery("Win32_VideoController");
            ManagementObjectSearcher searchVideo = new ManagementObjectSearcher(queryVideo);
            foreach (ManagementObject video in searchVideo.Get())
            {
                Console.WriteLine("Video device: {0}", video["Name"]);
            }

            Console.ReadLine();
        }
    }
}

WMI .NET Overview

After posting noticed it wasn't marked .NET, however this could be of interest as well. Creating a WMI Application Using C++




回答2:


I think your best bet is the DirectSound API, documented here: http://msdn.microsoft.com/en-us/library/bb219833%28VS.85%29.aspx

Specifically, the DirectSoundEnumerate call.



来源:https://stackoverflow.com/questions/481179/retrieving-graphics-sound-card-information-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!