locked
Get a List of DMR Devices

    Question

  • I am trying to get a list of devices that are audio rendering devices. The property that I want to filter by does not have a canonical name. Its: {78C34FC8-104A-4ACA-9EA4-524D52996E57},97

    Here is what I am trying to do.

    string[] properties = { "System.ItemNameDisplay", "System.Devices.ModelName", "System.Devices.Connected", "System.Devices.IsNetworkConnected",
                                      "{78C34FC8-104A-4ACA-9EA4-524D52996E57} 97"};
                string deviceSelector = "\"{78C34FC8-104A-4ACA-9EA4-524D52996E57} 97\":=\"Multimedia.DMR\"";
                //string deviceSelector = Windows.Media.Devices.MediaDevice.GetAudioRenderSelector();
                //string deviceSelector = "System.Devices.InterfaceClassGuid:=\"{8660e926-ff3d-580c-959e-8b8af44d7cde}\" AND System.Devices.InterfaceEnabled:=System.StructuredQueryType.Boolean#True";
                //string deviceSelector = "System.Devices.PrimaryCategory:=Multimedia.DMR";
    
                var pnpobjects = await PnpObject.FindAllAsync(PnpObjectType.DeviceContainer, properties, deviceSelector);

    Without the filter the PKEY_DeviceDisplay_PrimaryCategory has the value I am looking for: "Multimedia.DMR". How do I structure the filter property without the canonical name of the property?

    Thanks for your help.

    Wednesday, February 18, 2015 6:54 AM

All replies

  • It's hard to, http://www.codeproject.com/Articles/458550/Device-enumeration-in-Windows

    The second argument props is an IEnumerable(Of String). Here you have to explicitly list out which properties you want to retrieve. It will only give back information about the properties you asked for. In this case I have asked for three properties. Many properties have easy-to-remember string names, like the first two. But other properties don't, and you have to call them by their "canonical name" (consisting of an all-caps GUID and an integer). The canonical names are all defined in header files in the Windows SDK. I have also written them all in VB, in the accompanying source code.


    Best Regards,
    Please remember to mark the replies as answers if they help

    Thursday, February 19, 2015 5:20 AM
  • string[] properties = { "System.ItemNameDisplay", "System.Devices.ModelName", "System.Devices.Connected", "System.Devices.IsNetworkConnected",
                                      "{78C34FC8-104A-4ACA-9EA4-524D52996E57} 97"};
    // I can retrieve property as above
    
    //the problem is how do I filter by the property since it does not have a canonical name

    Thanks for your response. I wrote the initial post in wee hours of the AM and I wasn't clear.

    I don't have a problem retrieving the property. The problem is filtering by it. What I want to be able to do is below...

     string deviceSelector = "\"{78C34FC8-104A-4ACA-9EA4-524D52996E57} 97\":=\"Multimedia.DMR\"";
    
    //this line fails - it does not like format of deviceSelector because of the {GUID} XX:= fortmat.
    var pnpobjects = await PnpObject.FindAllAsync(PnpObjectType.DeviceContainer, properties, deviceSelector);
    The question is how can I use the "{GUID} XX" in the filter parameter of the FindAllAsync method.
    Thursday, February 19, 2015 3:13 PM
  • string[] properties = { "System.ItemNameDisplay", "System.Devices.ModelName", "System.Devices.Connected", "System.Devices.IsNetworkConnected",
                                      "{78C34FC8-104A-4ACA-9EA4-524D52996E57} 97"};
    // I can retrieve property as above
    
    //the problem is how do I filter by the property since it does not have a canonical name

    Thanks for your response. I wrote the initial post in wee hours of the AM and I wasn't clear.

    I don't have a problem retrieving the property. The problem is filtering by it. What I want to be able to do is below...

     string deviceSelector = "\"{78C34FC8-104A-4ACA-9EA4-524D52996E57} 97\":=\"Multimedia.DMR\"";
    
    //this line fails - it does not like format of deviceSelector because of the {GUID} XX:= fortmat.
    var pnpobjects = await PnpObject.FindAllAsync(PnpObjectType.DeviceContainer, properties, deviceSelector);
    The question is how can I use the "{GUID} XX" in the filter parameter of the FindAllAsync method.

    Rer MSDN: https://msdn.microsoft.com/en-us/library/windows/apps/hh825872.aspx

    Use the id of the object you started with (from the heading row) and the property you identified in the table, to form an AQS string of the form "<property>:=<id>".

    As an example, if we wanted to find all interfaces in a container with identity "{1451362b-4b9c-4780-a4bf-6c001619646c}" then the AQS string would be "System.Devices.ContainerId:={1451362b-4b9c-4780-a4bf-6c001619646c}".

    Note  When working with properties that contain GUIDs, the GUID value must be placed in braces when forming the AQS string.


    Best Regards,
    Please remember to mark the replies as answers if they help

    Friday, February 20, 2015 9:41 AM
  • Thanks for your response but the proper value is not a GUID the property name is a GUID. There does not seem to be a canonical name for the property: ""{78C34FC8-104A-4ACA-9EA4-524D52996E57} 97". I tried to guess at it based on the naming convention of the others and the code in the project here.

    http://www.codeproject.com/Articles/458550/Device-enumeration-in-Windows

    Based on the above project it applies the constant: "PKEY_DeviceDisplay_PrimaryCategory"

    So I tried to guess at the name as "System.DiviseDisplay.PrimaryCategory". But this does not work.

    Also if I use the GUID name for other properties like "System.ItemNameDisplay" it is converted in the results. For example the following code will yield the following results:

    string[] properties = { "{B725F130-47EF-101A-A5F1-02608C9EEBAC},10", "{78C34FC8-104A-4ACA-9EA4-524D52996E57},97"};
    var pnpobjects = await PnpObject.FindAllAsync(PnpObjectType.DeviceContainer, properties);
    
    foreach (PnpObject pnp in pnpobjects)
                {
                   foreach (KeyValuePair<string, object> kvp in pnp.Properties)
                    {
                        Debug.WriteLine(string.Format("ProperName: {0} PropertyValue {1}", kvp.Key, kvp.Value));
                    }}

    The above will output the following:

    ProperName: System.ItemNameDisplay PropertyValue DENON:[AVR-1613]
    ProperName: {78C34FC8-104A-4ACA-9EA4-524D52996E57} 97 PropertyValue Multimedia.DMR

    Its converts the GUID propery name {B725F130-47EF-101A-A5F1-02608C9EEBAC},10 into "System.ItemNameDisplay" but it leaves {78C34FC8-104A-4ACA-9EA4-524D52996E57} 97 as is.

    I want to filter by the property "{78C34FC8-104A-4ACA-9EA4-524D52996E57} 97" in the AQS string. But I can't without knowing the canonical name for this property or a syntax where I can use the GUID name.

    How can I find the canonical name for this property or what syntax can I use to query by it in the AQS string?

    Sunday, February 22, 2015 7:04 PM