alexandram
asked on
List available COM ports
I have a screen from which users select a COM port. Instead of just listing COM1... COM8 in a listbox, I would like to display available com ports only.
ASKER
Thank you. I guess I won't bother since my application runs on both 95 and NT.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you.
One thing to note about port names is that traditionally they have
been COM1, COM2, COM3, or COM4. The Win32 API does not provide any
mechanism for determining what ports exist on a system. Windows NT and
Windows 95 keep track of installed ports differently from one another,
so any one method would not be portable across all Win32 platforms.
Some systems even have more ports than the traditional maximum of
four. Hardware vendors and serial-device-driver writers are free to
name the ports anything they like. For this reason, it is best that
users have the ability to specify the port name they want to use. If a
port does not exist, an error will occur (ERROR_FILE_NOT_FOUND) after
attempting to open the port, and the user should be notified that the
port isn't available.
So that you should enumerate them by checking the registry:
HKEY_LOCAL_MACHINE\System\
HKEY_LOCAL_MACHINE\Hardwar
However, in Win95/NT, the location might be slightly different.