Hi, how can I get the list of Serial comm ports of my pc?

Thx.
Posted on 2007-07-03 08:29:27 by _OuzO_
QueryDosDevice - then walk through the com ones, even then though they might be virtual ports...

if you're 2k or higher -> look at this http://www.codeproject.com/system/setupdi.asp
Posted on 2007-07-03 09:37:18 by evlncrn8
Thanks alot, even if it's not exactly what I expected.

I tried the code snippet you suggested which at first calls GetLogicalDriveStrings

and then loops calling QueryDosDevice with the various logical drives of the PC (i.e. A:, C:, and so on).
It works, but it does not retrieve the list of serial comm ports.  :sad:

I tried with
INVOKE QueryDosDevice, null, szName, BUFSIZE  ;  null as 1st param

but the function fails and GetlastError returns 7Ah (which is array not sufficient, too short).

Should I initialize in some way the destination array?
Any hint/code snippet is welcome.

Cheers
_OuzO_
Posted on 2007-07-04 10:26:54 by _OuzO_

I tried with
INVOKE QueryDosDevice, null, szName, BUFSIZE  ;  null as 1st param

but the function fails and GetlastError returns 7Ah (which is array not sufficient, too short).

Should I initialize in some way the destination array?


make a bigger buffer then, keep calling until you get success or you get bored...
65kb or so should be sufficient...

initialise the destination array.. sure, but i think the os does that anyway upon success


Any hint/code snippet is welcome.


nope, clearly you didnt bother researching that api at all, go hit msdn...
read up on it, then you'll understand how to use it properly...

it does report com ports for sure...

example from my pc -> COM1
\Device\Serial0


Posted on 2007-07-04 17:03:03 by evlncrn8