试一试这个
ManagementObjectSearcher mo =
new ManagementObjectSearcher("select * from Win32_SoundDevice");foreach (ManagementObject soundDevice in mo.Get())
{
String deviceId = soundDevice.GetPropertyValue("DeviceId").ToString();
String name = soundDevice.GetPropertyValue("Name").ToString(); //saving the name and device id in array
}
ManagementObjectSearcher mo =
new ManagementObjectSearcher("select * from Win32_SoundDevice");foreach (ManagementObject soundDevice in mo.Get())
{
String deviceId = soundDevice.GetPropertyValue("DeviceId").ToString();
String name = soundDevice.GetPropertyValue("Name").ToString(); //saving the name and device id in array
}
http://stackoverflow.com/questions/1809190/how-to-identify-the-default-audio-devices-from-a-net-application
我在winodws 7上试验了IMMDeviceEnumerator::GetDefaultAudioEndpoint, and then use MMDevice::GetId的方法,参考了网上的一个调整音量的例子。
结果IMMDeviceEnumerator::GetDefaultAudioEndpoint执行正常,能够得到device,下一步MMDevice::GetId取不到值。
明天再试试waveOutGetDevCaps using deviceID=WAVE_MAPPER (-1) 的方法。再次感谢。