问题
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