locked
Metro style equivalent

    Question

  • Is there any metro style equivalent of the API CM_Get_DevNode_Registry_PropertyW()? I am trying to read the property corresponding to the flag CM_DRP_CONFIGFLAGS of a device from registry. I have got the device by the device enumeration API of WinRT from Windows.Devices.Enumeration namespace. Thanks in advance.

    Tuesday, March 20, 2012 2:47 PM

Answers

  • I don’t know exactly why you need to know if the driver has been installed, but please note that having the driver installed is not enough to know that you can start using the device.  For that you need to wait for the interface that you need to use to become enabled. I mention this because a lot of people get tripped up by this.

    System.Device.DeviceHasProblem indicates, as the name describes that something is wrong with the device.  Most commonly it means that the device needs a driver and the system could not find one.  There a lot of other thing that could also indicate a problem.  You can examine the problem code set on the device by examining the DEPKEY_Device_ProblemCode.  From devpkey.h:
    (DEFINE_DEVPROPKEY(DEVPKEY_Device_ProblemCode, 0x4340a6c5, 0x93fa, 0x4706, 0x97, 0x2c, 0x7b, 0x64, 0x80, 0x08, 0xa5, 0xa7, 3);     // DEVPROP_TYPE_UINT32

    The valid problem codes are defined in cfg.h.  See the CM_PROB_* defines.

    Monday, March 26, 2012 5:05 PM

All replies

  • Moving to the Tailoring your Metro style app for hardware and devices forum for better assistance.

    David Lamb

    Tuesday, March 20, 2012 4:04 PM
    Moderator
  • Please take a look at the MSDN topic titled "How to retrieve additional properties for a device or PnP object".  It shows how to retrieve properties from device objects.  Config Flags is not a common property to want to use in a typical application and it does not have a friendly name but you can get it by requesting

    "{a45c254e-df1c-4efd-8020-67d16a850e0} 12"

    Why do you need to examine the config flags of a device?  Possibly there is a better way to get the information you need.

    • Proposed as answer by Bertus Greeff Tuesday, March 20, 2012 6:34 PM
    Tuesday, March 20, 2012 6:34 PM
  • Thank you Bertus!!. That was very helpful. In fact I need to get the Driver Description of a device and I have to do this after checking the value of this flag. In fact, I need to get the device properties of a printer like device name, dev node, deriver description etc and I am using DeviceEnumeration API  of Windows.Devices.Enumeration namespace . I have obtained most of the information referring to the MSDN topic u mentioned in the post. Well, I have a general question about the syntax "{a45c254e-df1c-4efd-8020-67d16a850e0} 12". I have come across this in MSDN. The first string is the GUID of the interface as I understand. What about the second number suffix? How can I get this number corresponding to the property I need to get? How would I know which number maps to which property?

    Also you mentioned a better way to get the information I need. Could you please explain?

    Wednesday, March 21, 2012 4:58 AM
  • The “GUID Pid” format is a string representation of a DEVPKEY structure.  This structure is used as a key to identify the property.  The GUID part identifies the "namespace” for the property and has nothing to do with the interface class guid.

    There are hundreds of these properties.  For some Microsoft has documented the meaning publicly, some not.  We give the most common ones canonical names and these properties can be relied upon to be available in a forward and backward compatible way.  Properties that are not documented are likely to change or be removed in future releases.

    You can see the complete list of public DEVPKEYs in devpkey.h in the Windows SDK.  The names are pretty descriptive, many are documented in the MSDN topic titled "System-Defined Device Properties"

    ConfigFlags are not a value that I’d expect an application to examine.  Why do you need to do it?  Is it because you are trying to figure out if the driver has already been
    installed?

    Thursday, March 22, 2012 5:30 PM
  • Thank you, Bertus. Yes, I need to check if the diver has already been installed. I have one question regarding this. There is a property called  System.Devices.DeviceHasProblem the Device object. On what basis does the API decide that a particular devnode has a problem? I suppose the Device here is a PnpObjectType. I guess the device can represent a particular devnode. So how does it understand that it has a problem so that we get the value in the property System.Devices.DeviceHasProblem?

    Friday, March 23, 2012 5:05 AM
  • I don’t know exactly why you need to know if the driver has been installed, but please note that having the driver installed is not enough to know that you can start using the device.  For that you need to wait for the interface that you need to use to become enabled. I mention this because a lot of people get tripped up by this.

    System.Device.DeviceHasProblem indicates, as the name describes that something is wrong with the device.  Most commonly it means that the device needs a driver and the system could not find one.  There a lot of other thing that could also indicate a problem.  You can examine the problem code set on the device by examining the DEPKEY_Device_ProblemCode.  From devpkey.h:
    (DEFINE_DEVPROPKEY(DEVPKEY_Device_ProblemCode, 0x4340a6c5, 0x93fa, 0x4706, 0x97, 0x2c, 0x7b, 0x64, 0x80, 0x08, 0xa5, 0xa7, 3);     // DEVPROP_TYPE_UINT32

    The valid problem codes are defined in cfg.h.  See the CM_PROB_* defines.

    Monday, March 26, 2012 5:05 PM