Get the full name of the sound device from Windows

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

I can use MIXERCAPS, but the szPname member will contain 32 characters (including NULL). For the name of the Microphone (High Definition Audio Unit) audio device, I will return only Auditor High Audence. This is because MAXPNAMELEN is defined as 32. I tried to redefine it to a larger number without effect.

Here is the code I'm using:

MIXERCAPS mc;
ZeroMemory( &mc, sizeof(MIXERCAPS) );
mm = mixerGetDevCaps( reinterpret_cast<UINT_PTR>(m_hMixer), &mc, sizeof(MIXERCAPS) );

I saw this question , but it refers to Vista and later.

+5
source share
3 answers

Windows Multimedia, , , MAXPNAMELEN, Windows.

, DirectSound. , , .

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
    }
}
+1

devcon. - Microsoft .

, devcon listclass media , .

0

(Delphi):

DirectShow/ActiveX, DirectSound, WaveOut.

procedure EnumAudioDevices;
var
  dsCreateDevEnum  : ICreateDevEnum;
  EnumDevice       : IEnumMoniker;
  DeviceMoniker    : IMoniker;
  Data             : Integer;
  DevicePropBag    : IPropertyBag;
  DeviceName       : OLEVariant;
  I                : Integer;
begin
  // CLSID_CQzFilterClassManager = Entire DirectShow Filter List
  If CoCreateInstance(CLSID_SystemDeviceEnum,nil,CLSCTX_INPROC_SERVER,IID_ICreateDevEnum,dsCreateDevEnum) = S_OK then
  Begin
    If dsCreateDevEnum.CreateClassEnumerator(CLSID_AudioRendererCategory,EnumDevice,0) = S_OK then
    Begin
      I := 0;
      EnumDevice.Reset;
      While EnumDevice.Next(1,DeviceMoniker,@Data) = S_OK do
      Begin
        If DeviceMoniker.BindToStorage(nil,nil,IID_IPropertyBag,DevicePropBag) = NOERROR then
        Begin
          If DevicePropBag.Read('FriendlyName',DeviceName,nil) = NOERROR then
          Begin
            // Success
            ShowMessage(DeviceName);
            Inc(I);
          End;
          DevicePropBag := nil;
        End;
        DeviceMoniker := nil;
      End;
      EnumDevice := nil;
    End;
    dsCreateDevEnum := nil;
  End;
End;
0

All Articles