Hello All.
I'm wondering (since I can't find it) if there is a way in .NET to enumerate Sound Devices on a client system. I know that there is a way in DirectX, but I can't seem to find it in .NET. My app allows the user to toggle sound effects, but there is no point if there are no Sound Devices installed or functional. Thanks for your help.

Enumerating Sound Devices
Ben Santiago
ImagineNation
use the Managed DirectX SDK - I believe this is the only way you can do this in .NET using managed libraries.
There are also examples on how to do such things in the SDK
Mantorok
Hello All.
Thanks, Scott, for your response. Yes, that's what I was looking for. I already knew that I could do it by referencing the DirectX library, but I didn't want to do that so I could try and keep the footprint as small as reasonably possible. This is exactly what I was after, even if it is a little out of the way. Thanks again.
Carl Bateman
Sutha Thiru
forwheeler
I need to brush up on my 2.0 framework skills.
I am still doing a lot with 1.1 .
Sorry about that :)
RobZeilinga
Johnnie B.
Hello All.
Thanks, Matthijs, for your response. Actually, .NET has quite a bit of support for sound playback in the System.Media class. I've bundled several .wav files as resources and the thing will play them all day long. I just didn't know whether or not .NET would let me enumerate Sound Devices, without referencing MDX or going to unmanaged code. Thanks again for your response.
spshah
Hello All.
Thanks, Ahmed, for your response. Yes, I know that it can be done via the DirectX library. I was wondering if there were a way to do it in .NET. I'm trying to keep the footprint as small as possible, which is hard enough with .NET. Thanks again.
TheBlackhorse
With WMI you can get at most hardware information. The API is quirky, though. You'll need to add a reference to System.Management.
When I use this code:
using System.Management;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
ObjectQuery query = new ObjectQuery();
query.QueryString = "SELECT * FROM Win32_SoundDevice";
// connect to local machine
ManagementScope scope = new ManagementScope(@"\\.\root\cimv2");
ManagementObjectSearcher searcher = new ManagementObjectSearcher();
searcher.Query = query;
searcher.Scope = scope;
ManagementObjectCollection devices;
devices = searcher.Get();
foreach(ManagementObject device in devices)
{
foreach(PropertyData property in device.Properties)
{
Console.WriteLine("{0}: {1}",
property.Name,
property.Value);
}
}
}
}
}
Then I get the following output on my m200 tablet:
Availability:
Caption: SoundMAX Integrated Digital Audio
ConfigManagerErrorCode: 0
ConfigManagerUserConfig: False
CreationClassName: Win32_SoundDevice
Description: SoundMAX Integrated Digital Audio
DeviceID: PCI\VEN_8086&DEV_24C5&SUBSYS_02C51179&REV_03\3&61AAA01&0&FD
DMABufferSize:
ErrorCleared:
ErrorDescription:
InstallDate:
LastErrorCode:
Manufacturer: Analog Devices, Inc.
MPU401Address:
Name: SoundMAX Integrated Digital Audio
PNPDeviceID: PCI\VEN_8086&DEV_24C5&SUBSYS_02C51179&REV_03\3&61AAA01&0&FD
PowerManagementCapabilities:
PowerManagementSupported: False
ProductName: SoundMAX Integrated Digital Audio
Status: OK
StatusInfo: 3
SystemCreationClassName: Win32_ComputerSystem
SystemName: M200
Hope that helps,