- device path: how to get long device path instead of short?
- Posted by Eugen on July 27th, 2004
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
- Posted by Maxim S. Shatskih on July 27th, 2004
Why storing the paths? Not necessary at all. Just re-run
SetupDiGetClassDevs each time you need to open a COM port.
--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com
"Eugen" <zhenja@zlo.ee> wrote in message
news:%23nbxfs%23cEHA.644@tk2msftngp13.phx.gbl...
- Posted by Alexander Grigoriev on July 27th, 2004
Use QueryDosDevices to obtain a list of all symbolic links.
"Eugen" <zhenja@zlo.ee> wrote in message
news:%23nbxfs%23cEHA.644@tk2msftngp13.phx.gbl...
- Posted by Jim Cavalaris [MS] on July 27th, 2004
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...tclassdevs.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...interfaces.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...facedetail.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...seovr_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...-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.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Eugen" <zhenja@zlo.ee> wrote in message
news:%23nbxfs%23cEHA.644@tk2msftngp13.phx.gbl...