Get the full audio device name from Windows

前端 未结 3 2023
忘了有多久
忘了有多久 2020-12-19 11:32

Is there a way to get the full audio device name in Windows XP and later?

I can use MIXERCAPS but the szPname member will limit to 32 characters (in

3条回答
  •  温柔的废话
    2020-12-19 12:02

    If you use the classic Windows Multimedia interface you probably can't get around the MAXPNAMELEN limitation, since that's compiled into Windows itself.

    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 *names = (std::vector*)ctx;
        names->push_back(std::string(descr));
        return TRUE;
    }
    
    int main()
    {
        std::vector names;
        if (!FAILED(DirectSoundEnumerate(&EnumCallback, &names)))
        {
            // do stuff
        }
    }
    

提交回复
热议问题