Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Programatially figure out USB assigned COM port for a modem device

288 views
Skip to first unread message

Hetal

unread,
May 6, 2002, 3:57:36 PM5/6/02
to
Hey ...

thanks for the info you sent earlier. I had some more detailed
questions:

When enumerating devcies if the Port class, I guess I'd have to first
use SetupDiGetClassDevs() function. One of the parameters to this is a
pointer to a classGUID. How do I pass that it. Are these defined
somewhere. I found out for eg ... that the ClassGUId for Ports class
is: ClassGuid = {4d36e978-e325-11ce-bfc1-08002be10318} . How would I
create a pointer to this and pass it in the function.

Am I on the right track?

thanks,
Hetal.


From: Eliyas Yakub (eli...@microsoft.com)
Subject: Re: Programatially figure out USB assigned COM port for a
modem device
Newsgroups: comp.os.ms-windows.programmer.nt.kernel-mode
View this article only
Date: 2002-02-05 10:07:29 PST

Enumerate devices of the Ports class and first get the
SPDRP_ENUMERATOR_NAME
using SetupDiGetDeviceRegistryProperty. If the enumerator is USB then
get
the FriendlyName (SPDRP_FRIENDLYNAME) using the same function. The
friendlyname gives you the COM port name.

You can modify the PrintToasterDeviceInfo function in
src\general\toaster\exe\toast.c of XP DDK to easily achieve this.

--
-Eliyas
This posting is provided "AS IS" with no warranties, and confers no
rights.
You assume all risk for your use.

Eliyas Yakub

unread,
May 6, 2002, 5:21:49 PM5/6/02
to
devInfo = SetupDiGetClassDevs((LPGUID)&GUID_DEVCLASS_PORTS, NULL, NULL,
DIGCF_PRESENT );

--
-Eliyas
This posting is provided "AS IS" with no warranties, and confers no rights.


"Hetal" <Patel...@msn.com> wrote in message
news:e10a28.020506...@posting.google.com...

Hetal

unread,
May 7, 2002, 7:01:27 PM5/7/02
to
Thanks again! I managed to get to that finally, but I'm still not able
to get to my final goal as below.

I am using a USB modem device. I want to figure out the Virtual COM
port assinged to this device programatically so I can communicate with
it. The problem I'm facing is this:

If I use enumerate devices of the ports class, it does not list the
USB assigned (Virtual) COMM ports even when the device is on, so the
other functions mentioned will not get any info on that.

If I use the modem class, then the available options for the
SetupDiGetDeviceRegistryProperty function such as SPDRP_FRIENDLYNAME
or SPDRP_DEVICEDESC gets the name of the modem eg. "My Modem" from the
registry setting correspoding the DeviceDesc or Friendlyname. However,
I am looking for the port number (which is the AttachedTo registry
setting). I am not able to get the COMM port number for a USB modem.

Is there any way ... API's I could use to figure out the Virtual COMM
port assigned to my USB modem device?

Also, the code I wrote for Windows 2K to list all the modem devices
installed does not work for Windows ME? Is there a different set of
files I have to use from another DDK?

thanks in advance,
Hetal Patel


"Eliyas Yakub" <eli...@microsoft.com> wrote in message news:<3cd6f3e9$1...@news.microsoft.com>...

Eliyas Yakub

unread,
May 7, 2002, 8:11:58 PM5/7/02
to
I will speak only for Win2K. Since I don't have modem on my systems here,
please tell me by going thru the registry where exactly the Port information
is present and I will tell how to get that using SetupDi. Please give me the
registry path.

--
-Eliyas
This posting is provided "AS IS" with no warranties, and confers no rights.


"Hetal" <Patel...@msn.com> wrote in message

news:e10a28.020507...@posting.google.com...

Hetal

unread,
May 9, 2002, 10:13:26 AM5/9/02
to
Hey Eliyas,

Thanks for your response. The registry path that I am refering to for
Win 2K is

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Control\Class\{4D36E96D-E325-11CE-BFC1-08002BE10318}\0001

where the modem settings/properties would be under 0001. In my case it
is a USB modem.
Name of Value: AttachedTo
Type : REG_SZ
Data: COM4

I am interested in getting the data value ie COM4. With the different
tests I tried, I was able to get
"{4D36E96D-E325-11CE-BFC1-08002BE10318}\0001" when I pass SPDRP_DRIVER
to the SetupDiGetDeviceRegistryProperty function.

It is interesting that you mentioned only Win 2k. Because I wrote a
small program to enumerate available modem devices on my Windows 2K
m/c using the SetupDi fns and it worked, but when I used the same
program also building it on windows ME, it doesn't work? any idea on
this? are there a different set of functions for Win ME ... do the
SetupDi fnS work on Win ME?

thanks,
Hetal.


"Eliyas Yakub" <eli...@microsoft.com> wrote in message news:<3cd86d4e$1...@news.microsoft.com>...

Eliyas Yakub

unread,
May 9, 2002, 1:36:45 PM5/9/02
to
That's not the way to do. You should use SetupDiOpenDevRegKey(DIREG_DRV) to
get a handle to the driver instance key
(HKLM\SYSTEM\CurrentControlSet\Control\Class\ClassGUID\InstanceID) and then
use RegQueryValueEx functions to read the value.

--
-Eliyas
This posting is provided "AS IS" with no warranties, and confers no rights.

"Hetal" <Patel...@msn.com> wrote in message

news:e10a28.020509...@posting.google.com...

0 new messages