locked
How do I get the Category of the containerID?

    Question

  • When I go to Control Panel --> Device and Printers I see that there is a category for the computer. I can get some metadata from the containerID for the computer itself. But I can't get Category which it belongs to. I see in the bottom of the page that it shows which category it belongs to. But when try to specify the property System.Devices.Category it always return null.

    The reason I ask this is because I want to know in the metro app if the unit is a desktop or a notebook.

    Thank you in advance

    Thursday, March 1, 2012 8:33 PM

Answers

  • Hi Lex,

    System.Devices.Category was introduced in Win7 for use through Devices and Printers (D&P). D&P extensions could use the canonical name to get the category to display.  Due to this, System.Devices.Category maps to DEVPKEY_DeviceContainer_Category_Desc_Singular not DEVPKEY_DeviceContainer_Category.  In your case you're really after DEVPKEY_DeviceContainer_Category. From DevPkey.h


    DEFINE_DEVPROPKEY(DEVPKEY_DeviceContainer_Category, 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 90); // DEVPROP_TYPE_STRING_LIST
    DEFINE_DEVPROPKEY(DEVPKEY_DeviceContainer_Category_Desc_Singular, 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 91); // DEVPROP_TYPE_STRING_LIST

    For now, if you want to get at DEVPKEY_DeviceContainer_Category you must use the the GUID + PID form through the Windows.Devices.Enumeration API. As Eric mentioned, "{78c34fc8-104a-4aca-9ea4-524d52996e57} 90” is what you want.  This should return an array of strings, not a single string as the underlying property type is DEVPROP_TYPE_STRING_LIST. Keep that in mind when working with your JS code.

    If you still have problems getting the category, you can double check your PC is getting a category properly assigned by running this command line:

    start /wait ddodiag.exe -o output.xml

    Open output.xml and look for the parent node <DDO instanceId="DDO:{00000000-0000-0000-FFFF-FFFFFFFFFFFF}">. That node represents the container of the PC.  Under that node you should see a <PropertyStore propertyCount="XX">.  This contains all the properties on the container. Under there look for the entry for PKEY_DeviceDisplay_Category and see what is listed. You should see at least one device category.

    Thanks,
    Ben

    Tuesday, March 20, 2012 2:09 AM

All replies

  • Lex,

    I am looking into this. 

    Best Wishes - Eric

    Wednesday, March 7, 2012 7:10 PM
    Moderator
  • Lex,

    Why is it important to know if this is a desktop or a notebook?

    Best Wishes - Eric

    Wednesday, March 7, 2012 11:11 PM
    Moderator
  • Hi Eric, thank you for the reply. In my app the user can register her/himself. In my case is because I want to know which form factor is most popular in my user base.

    Thank you once again

    Wednesday, March 14, 2012 3:48 PM
  • Lex,

    You can use the GUID PID form of DEVPKEY_DeviceDisplay_Category http://msdn.microsoft.com/en-us/library/windows/hardware/ff542348(v=VS.85).aspx
    Example:

    "{78c34fc8-104a-4aca-9ea4-524d52996e57} 90”

    Please note that it is important to avoid form factor specific app designs. The app should work the same across all form factors. 

    Best Wishes - Eric

    Thursday, March 15, 2012 2:26 AM
    Moderator
  • Hi Eric, thank you for posting a reply. But I am still having problems.

    If I understood right (and after reading some references) if there is no canonical name I can use the format {GUI} pid. And indeed I made a test. I was able to retrieve System.Devices.ModelName and when I try to use the format "{656A3BB3-ECC0-43FD-8477-4AE0404A96CD} 8194" I get the same value.

    My code is JavaScript and I am making use of

    Windows.Devices.Enumeration.Pnp.PnpObject.findAllAsync

    where as properties to retrieve I am passing an array (trying the canonical name or the {guid} pid).

    My understanding is that every device container has a category associated to it. Is that right?

    Also using this URL as reference: http://msdn.microsoft.com/en-us/library/windows/desktop/dd391623(v=vs.85).aspx I could not find the pid 90 (I did find 91 to 94 for the categories but all of them return null).

    Yeap. I trying to get this information but I am not making any UI change based on that. Thanks for the heads up.

    Thank you once again

    Lex


    • Edited by Lex_BR Sunday, March 18, 2012 10:38 PM note about UI included
    Sunday, March 18, 2012 10:33 PM
  • Hi Lex,

    System.Devices.Category was introduced in Win7 for use through Devices and Printers (D&P). D&P extensions could use the canonical name to get the category to display.  Due to this, System.Devices.Category maps to DEVPKEY_DeviceContainer_Category_Desc_Singular not DEVPKEY_DeviceContainer_Category.  In your case you're really after DEVPKEY_DeviceContainer_Category. From DevPkey.h


    DEFINE_DEVPROPKEY(DEVPKEY_DeviceContainer_Category, 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 90); // DEVPROP_TYPE_STRING_LIST
    DEFINE_DEVPROPKEY(DEVPKEY_DeviceContainer_Category_Desc_Singular, 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 91); // DEVPROP_TYPE_STRING_LIST

    For now, if you want to get at DEVPKEY_DeviceContainer_Category you must use the the GUID + PID form through the Windows.Devices.Enumeration API. As Eric mentioned, "{78c34fc8-104a-4aca-9ea4-524d52996e57} 90” is what you want.  This should return an array of strings, not a single string as the underlying property type is DEVPROP_TYPE_STRING_LIST. Keep that in mind when working with your JS code.

    If you still have problems getting the category, you can double check your PC is getting a category properly assigned by running this command line:

    start /wait ddodiag.exe -o output.xml

    Open output.xml and look for the parent node <DDO instanceId="DDO:{00000000-0000-0000-FFFF-FFFFFFFFFFFF}">. That node represents the container of the PC.  Under that node you should see a <PropertyStore propertyCount="XX">.  This contains all the properties on the container. Under there look for the entry for PKEY_DeviceDisplay_Category and see what is listed. You should see at least one device category.

    Thanks,
    Ben

    Tuesday, March 20, 2012 2:09 AM
  • Hi Ben, thank you for the information. really good stuff.

    Something interesting happened. I tried to user {78c34fc8-104a-4aca-9ea4-524d52996e57} 90, as Eric suggested, and it returned null (tried several times). But after I ran the ddodiag that you suggested I saw the information over there and when I ran the code with {78c34fc8-104a-4aca-9ea4-524d52996e57} 90 I managed to get an array with the info.

    Thank you Ben and Eric for the help.

    Tuesday, March 20, 2012 4:47 PM