获得从Windows完整的音频设备名称 [英] Get the full audio device name from Windows
问题描述
有没有办法在Windows XP中获得的完全音频设备名称,以后呢?
Is there a way to get the full audio device name in Windows XP and later?
我可以使用MIXERCAPS但szPname成员将限制在32个字符(包括NULL)。对于麦克风(高清晰度音频设备)的音频设备名称,我只拿回麦克风(高清晰度澳元。这是由于MAXPNAMELEN被定义为32.我已经尝试过重新定义为更大的数字没有效果
I can use MIXERCAPS but the szPname member will limit to 32 characters (including NULL). For an audio device name of "Microphone (High Definition Audio Device)", I only get back "Microphone (High Definition Aud". This is due to MAXPNAMELEN being defined to 32. I have tried redefining it to a larger number to no effect.
下面是code我使用的:
Here is the code I am using:
MIXERCAPS mc;
ZeroMemory( &mc, sizeof(MIXERCAPS) );
mm = mixerGetDevCaps( reinterpret_cast<UINT_PTR>(m_hMixer), &mc, sizeof(MIXERCAPS) );
我看到这个问题,但它引用Vista和更高版本。
I saw this question, but it references Vista and later.
推荐答案
如果您使用经典的Windows多媒体接口你可能无法得到解决的MAXPNAMELEN限制,因为这是编译成Windows本身。
If you use the classic Windows Multimedia interface you probably can't get around the MAXPNAMELEN limitation, since that's compiled into Windows itself.
然而,你也许可以,如果你使用的DirectSound,而不是得到完整的设备名称。下面code是未经检验的,但我认为它应该工作。
However you might be able to get the full device name if you use DirectSound instead. The following code is untested but I think it should work.
BOOL CALLBACK EnumCallback(LPGUID guid, LPCSTR descr, LPCSTR modname, LPVOID ctx)
{
std::vector<std::string> *names = (std::vector<std::string>*)ctx;
names->push_back(std::string(descr));
return TRUE;
}
int main()
{
std::vector<std::string> names;
if (!FAILED(DirectSoundEnumerate(&EnumCallback, &names)))
{
// do stuff
}
}
这篇关于获得从Windows完整的音频设备名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!