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.
    How to get this type of path?

    Please help
    Eugen, Jul 27, 2004
    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
    1. Advertisements

  3. Use QueryDosDevices to obtain a list of all symbolic links.
    Alexander Grigoriev, Jul 27, 2004
  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.


    [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.


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


    the symbolic link is the DevicePath field of the

    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:

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

    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 opens a registry storage key for device-specific
    configuration information and returns a handle to the key.

    DIREG_DEV -- Open a hardware key for the device.

    hope this helps,
    Jim Cavalaris [MS], Jul 27, 2004
    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.