The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Faktor on September 06, 2006, 09:01:26 AM

Title: List of com & lpt ports
Post by: Faktor on September 06, 2006, 09:01:26 AM
Hi !
Pardon my english.
Im new in MASM an in WIN32 programing ,i have some experience in DOS programing.
MASM RULES!
OK,i understand SOME of the principles of Win programing.
My question is:

How to get a list of all valid com & lpt ports in MASM ,on a specific PC in Win98 enviroment?


I think that ther is a list in Win98 registers under HKEY_LOCAL_MACHINE/Hardware/DeviceMap/SeriallComm..
and somting similar under ME and XP
This is not a physical list, but is identical to the control panel list.
For example, i'm making a program for RS232 com. and IO operations on LPT (under win98),and i dont whant to refer to a port that dosent exist.
I use atleast 2 COM ports and 1 LPT port.(diffrent physical hrdwarwe connections)

Shud i useĀ  GetLastError or some similar mechanisam?


Title: Re: List of com & lpt ports
Post by: anon on September 06, 2006, 01:58:17 PM
Look up CreateFile. What I did was test for COM1, COM2, etc. in a loop.
If CreateFile returns a valid handle, then that resource is available. You
then do the same thing for LPT1, LPT2, etc.
Title: Re: List of com & lpt ports
Post by: Faktor on September 07, 2006, 02:09:55 PM
Yes !
thanks Anon