1

Is there a good way to get the Device Instance path(e.g: USB\VID_021D&PID_0C51&MI_00\6&192CE49&4&0000) from Bus Relations (e.g:{0.0.1.00000000}.{4234a4c6-3535-49d6-971c-76ce1f22521e}) ?

I realize some terms in Windows have aliases, by "Device Instance path" and "Bus Relations", I mean the two properties found in the device manager: enter image description here

I have tried to get the Device Instance path from the PropertyStore

int getProperty(std::string& sampleID)
{
   HRESULT hr = S_OK;
   IMMDeviceEnumerator* pEnumerator = NULL;


   //CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);

   hr = CoCreateInstance(__uuidof(MMDeviceEnumerator),
       NULL,
       CLSCTX_INPROC_SERVER,
       __uuidof(IMMDeviceEnumerator),
       (void**)&pEnumerator);

   if (hr != S_OK)
   {
       // error cleanup
       return hr;
   }

   IMMDevice* pEndpoint = NULL;
   std::wstring wSampleID(sampleID.begin(), sampleID.end());
   hr = pEnumerator->GetDevice(wSampleID.c_str(), &pEndpoint);
   if (hr != S_OK || pEndpoint == NULL)
   {
       // error cleanup
       return hr;
   }

   if (!pEndpoint)
   {
       // error cleanup
       return hr;
   }

   IPropertyStore* pProps = NULL;
   hr = pEndpoint->OpenPropertyStore(
       STGM_READ, &pProps);

   PROPVARIANT varName;
   // Initialize container for property value.
   PropVariantInit(&varName);

   hr = pProps->GetValue(
       PKEY_AudioEndpoint_GUID, &varName);
   if (hr != S_OK)
   {
       //error cleanup
       return hr;
   }
   std::cout << varName.pwszVal << std::endl;

   PropVariantClear(&varName);
   SAFE_RELEASE(pProps)
   SAFE_RELEASE(pEndpoint)
   SAFE_RELEASE(pEnumerator);
   return hr;
}

but there does not seem to be a property key to retrieve this piece of information for Audio Endpoint IMMDevice. Any suggestion is appreciated.

3
  • Bus Relations - this is what and how you get it ? Commented Sep 15, 2020 at 7:28
  • @RitaHan-MSFT I have the Bus Relations (device GUID) of some composite devices with multiple interfaces. An example would be a headphone + microphone device which yields two Bus Relation strings, one for headphone and the other for microphone. My goal is to group the Bus Relations belonging to the same physical device. Since the Device Instance path contains information like PID, VID and some port-unique strings, getting these info will help me achieving my goal. Commented Sep 15, 2020 at 13:27
  • @RbMm Bus Relation is the Device GUID for an device, it can be retrieved from PropertyStore with key PKEY_AudioEndpoint_GUID. It can also be found in device manager -> device property -> Bus Relations. I got this GUID from Goodle Webrtc audio device enumeration. Commented Sep 15, 2020 at 13:32

1 Answer 1

1

An example would be a headphone + microphone device which yields two Bus Relation strings, one for headphone and the other for microphone. My goal is to group the Bus Relations belonging to the same physical device.

Bus Relations belonging to the same physical device have already been grouped and you can get it through "Bus relations" property of the same physical audio device (parent). You can find that via Device Manager (View -> Devices by connection) like this:

enter image description here

Is there a good way to get the Device Instance path(e.g: USB\VID_021D&PID_0C51&MI_00\6&192CE49&4&0000) from Bus Relations (e.g:{0.0.1.00000000}.{4234a4c6-3535-49d6-971c-76ce1f22521e}) ?

Although it is not clear that what grouped Bus relations will you use for. But you will find that not all (USB) devices have Device Instance path in this format: USB\VID_xxxx&PID_xxxx*. Take Microphone showed in above snapshot as an example, its Device Instance path like below, same with one of bus relations of its parent.

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.