locked
How can I get PrinterPropertyName property from device enumeration

    Question

  • Hi,

    I would like to get Port Name such as USB001, USB002,... or IP address from printer properties of devices in the 'Devices and Printers' of the 'Control Panel'. 

    According to MSDN, retreiving of property which don't have a canonical name by specifying the key as a string of the form of "{Guid} pid" (http://msdn.microsoft.com/en-us/library/windows/apps/hh464997.aspx) and System.DeviceInterface.PrinterPortName is defined as "{EEC7B761-6F94-41B1-949F-C729720DD13C} 12" in form of "{Guid} pid", therfore I called PnpObject.FindAllAsync() by modifying Device enumeration sample as follows: 

        string[] properties = { "System.ItemNameDisplay", "System.Devices.ModelName", "System.Devices.Connected", "{EEC7B761-6F94-41B1-949F-C729720DD13C} 12"};
        var containers = await PnpObject.FindAllAsync(PnpObjectType.DeviceContainer, properties);

    However, I can get name of property as "PrinterPortName" correctly but it seems value of devices are always null.

    It would be appreciated that if anyone to help me for retrieving Port Name of the devices.

    Thank you for your help in advance.


    • Edited by Giwon Seo Monday, March 5, 2012 10:13 AM
    Monday, March 5, 2012 10:13 AM

Answers

  • Hi Giwon,

    We don't support retrieving the IP address. The GUID you provided does correspond with a PrinterPortName, however, it is only ever published on a DeviceInterface object, not a DeviceContainer. Note, that this doesn't address your scenario of obtaining an IP address in many cases, as the port name is not required to match the IP address/host name of the device.

    http://msdn.microsoft.com/en-us/library/windows/desktop/dd562019(v=vs.85).aspx

    Thanks

    Justin

    Monday, March 12, 2012 5:26 PM

All replies

  • Hello, I am in the process of finding someone to help out here. Thanks for your patience.

    David Lamb

    Friday, March 9, 2012 9:03 PM
    Moderator
  • Hi Giwon,

    We don't support retrieving the IP address. The GUID you provided does correspond with a PrinterPortName, however, it is only ever published on a DeviceInterface object, not a DeviceContainer. Note, that this doesn't address your scenario of obtaining an IP address in many cases, as the port name is not required to match the IP address/host name of the device.

    http://msdn.microsoft.com/en-us/library/windows/desktop/dd562019(v=vs.85).aspx

    Thanks

    Justin

    Monday, March 12, 2012 5:26 PM
  • Hello Justin,

    Thank you for your clarification.

    It turned out that I did mistake. PortName is able to retreive using DeviceInterface object well.

    Thanks

    Friday, March 30, 2012 2:07 AM