Jignesh Sakariya

Hi,

I want to know how to identify endpoint audio device on windows vista.

I can get the device name by using "OpenPropertyStore()" of "IMMDevice" interface API but problem is that if I change the name of device manually at "General" tab of device property then i will get modified name.

I have also tried by using "GetId()" API but it is variable from system to system.

Please see the below code that I have tried out.

HRESULT hResult = E_FAIL;

CComPtr<IMMDeviceEnumerator> spEnumerator;

CComPtr<IPropertyStore> spProperties;

CComPtr<IMMDevice> spDevice;

////////////Create Instance of IMMDeviceEnumerator interface//////////

hResult = spEnumerator.CoCreateInstance(__uuidof(MMDeviceEnumerator));

if (FAILED(hResult))

{

printf("CoCreateInstance() API Filed");

}

////////////Retrive default audio end point of capture device//////////

hResult = spEnumerator->GetDefaultAudioEndpoint(eCapture, eMultimedia, &spDevice);

if (FAILED(hResult))

{

printf("GetDefaultAudioEndpoint() API Filed");

}

PROPVARIANT value;

PropVariantInit(&value);

////////////Open propertystore of retrived device//////////////

hResult = spDevice->OpenPropertyStore(STGM_READWRITE, &spProperties);

if (FAILED(hResult))

{

printf("OpenPropertyStore() API Filed");

}

////////////////Get the name of selected device//////////////////

hResult = spProperties->GetValue(PKEY_Device_DeviceDesc, &value);

if (FAILED(hResult))

{

printf("GetValue() API Filed");

}

CString szDevName(value.pwszVal);

printf("Device Name is::"+szPortName);

If any body knows then please help me.

Regards,

Jignesh Sakariya



Re: Vista Pro-Audio Application Development How to identify EndPointAudio device on Vista

Jignesh Sakariya

Use same code as above,

You can get type of device by,

hResult = spProperties->GetvAlue(PKEY_Device_FormFactor, &value);

Above properties gives the type of device.

Thanks & Regards,

Jignesh Sakariya