device path: how to get long device path instead of short?

Discussion in 'Windows Vista Drivers' started by Eugen, Jul 27, 2004.

  1. Eugen

    Eugen Guest

    Hi all

    I need to enumarate all COM ports and store their paths. Now I can do almost
    everything what I need:
    I use SetupDiEnumDeviceInfo to iterate through all ports. By this I find all
    ports in the system including LPT and COM.
    I add to the list only COM ports, and I have them with path COM1, COM2, etc.
    But I know, that in the system they have other real paths, e.g.
    \\?\acpi#pnp0501#1#{4d36e978-e325-11ce-bfc1-08002be10318
    How to get this type of path?

    Please help
     
    Eugen, Jul 27, 2004
    #1
    1. Advertisements

  2. Why storing the paths? Not necessary at all. Just re-run
    SetupDiGetClassDevs each time you need to open a COM port.
     
    Maxim S. Shatskih, Jul 27, 2004
    #2
    1. Advertisements

  3. Use QueryDosDevices to obtain a list of all symbolic links.
     
    Alexander Grigoriev, Jul 27, 2004
    #3
  4. use SetupDiGetClassDevs with the DIGCF_DEVICEINTERFACE flag, and
    specify the GUID for the COM port device interface class,
    GUID_DEVINTERFACE_COMPORT. this retrieves a set of COM port
    device interfaces.

    SetupDiGetClassDevs:
    http://msdn.microsoft.com/library/en-us/devio/base/setupdigetclassdevs.asp

    ClassGuid
    [in] Pointer to a class GUID for a setup class or an interface class.
    If the DIGCF_DEVICEINTERFACE flag is set, ClassGuid represents an
    interface class; otherwise, ClassGuid represents a setup class.

    enumerate the device info set with SetupDiEnumDeviceInterfaces, also
    specifying the GUID_DEVINTERFACE_COMPORT class GUID.

    SetupDiEnumDeviceInterfaces:
    http://msdn.microsoft.com/library/en-us/devio/base/setupdienumdeviceinterfaces.asp

    for each enumerated device interface (PSP_DEVICE_INTERFACE_DATA ),
    you can retrieve the symbolic link to the device with:

    SetupDiGetDeviceInterfaceDetail:
    http://msdn.microsoft.com/library/en-us/devio/base/setupdigetdeviceinterfacedetail.asp

    the symbolic link is the DevicePath field of the
    SP_DEVICE_INTERFACE_DETAIL_DATA structure.

    with SetupDiGetDeviceInterfaceDetail, you can also get the PSP_DEVINFO_DATA
    representing the device that the interface is registered against.

    if you also want the COM port name, it is stored as a reg value in the
    device's hardware key.

    Registry Settings for a Plug and Play COM Port:
    http://msdn.microsoft.com/library/en-us/serial/hh/serial/sseovr_4unb.asp

    All the following registry settings are under the Plug and Play registry
    key for a COM port.

    PortName
    The PortName entry value specifies the name of the COM port. The name of
    a COM port is typically COM<n>. However, a COM port name can be set to
    any non-NULL string. Serial uses the port name to create a symbolic link
    to the COM port that is visible in user-mode. PortName is a REG_SZ and
    the default value is an empty string.


    use SetupDiOpenDevRegKey and specify the DIREG_DEV key type to open
    the device's hardware key.

    SetupDiOpenDevRegKey
    http://msdn.microsoft.com/library/en-us/install/hh/install/di-rtns_8g36.asp

    SetupDiOpenDevRegKey opens a registry storage key for device-specific
    configuration information and returns a handle to the key.

    KeyType
    DIREG_DEV -- Open a hardware key for the device.

    hope this helps,
    jim.
     
    Jim Cavalaris [MS], Jul 27, 2004
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.