[Application] ListComPort - A simple COM port lister

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
User avatar
Azias
New User
New User
Posts: 7
Joined: Wed Oct 04, 2017 5:59 pm

[Application] ListComPort - A simple COM port lister

Post by Azias »

Hi,

I've recently been working quite a bit with microcontrollers, and I've noticed how annoying it can sometime be to find the relevant COM port for a new device in Windows straight from the command prompt, so I made a small application that combines the port listing capabilities of the mode command and the friendly names shown by the Device Manager by using Windows' registry directly.

The app is by no mean perfect, but it is relatively usefull when you need to find a COM port in a pinch without having to quit the command prompt or when you want to get it in another program relatively easily, so I thought it would be interesting to share it with you and on GitHub.

It should also work on any x86/x64 Windows machine that is running Windows XP x64/Vista or something newer.

Features:
* Can print raw names, device names and friendly names independently.
* The output can natively be formatted to CSV or Tab padded tables. (Arbitrary separators are possible)
* Most of the functionalities of the application are located in different independent modules.
* Relatively permissive error handling.
* Allows for quick alphabetical sorting.
* Fully translated in French.

Planned features:
* The possibility to see the list of known COM ports and the device that provides them.
* More formatting options.
* LPT ports support.

Problems remaining:
* Some friendly names cannot be linked to their respective raw name, I couldn't find a reliable link in the registry. (See COM1 in the Sample outputs section)

Source code, download links & license:
The application, as well as its source code and the executables can be found on GitHub at the following URL:
https://github.com/aziascreations/PB-ListComPort

The project is under the Unlicense license, so you can feel free to copy, modify and re-use every bit of code you would like.

Sample outputs:

Code: Select all

$ lscom -ats
CNCA0   com0com - serial port emulator CNCA0 (CNCA0)    \Device\com0com10
CNCB0   com0com - serial port emulator CNCB0 (CNCB0)    \Device\com0com20
COM1    No friendly name found (COM1)   \Device\Serial0
COM100  com0com - serial port emulator CNCA1 (COM100)   \Device\com0com11
COM101  com0com - serial port emulator CNCB1 (COM101)   \Device\com0com21
COM2    AX99100 PCIe to High Speed Serial Port (COM2)   \Device\StnSerial0
COM21   USB Serial Device (COM21)       \Device\USBSER000
COM3    AX99100 PCIe to High Speed Serial Port (COM3)   \Device\StnSerial1
COM8    com0com - serial port emulator CNCA3 (COM8)     \Device\com0com13
COM9    com0com - serial port emulator CNCB3 (COM9)     \Device\com0com23

Code: Select all

$ lscom -ntds
CNCA0   \Device\com0com10
CNCB0   \Device\com0com20
COM1    \Device\Serial0
COM100  \Device\com0com11
COM101  \Device\com0com21
COM2    \Device\StnSerial0
COM21   \Device\USBSER000
COM3    \Device\StnSerial1
COM8    \Device\com0com13
COM9    \Device\com0com23
Changelog:
V2.1.0
● Refactored the includes.
● Added more info to '-v'.
● Fixed the issue where port should have been shown in chronological order.
● Fixed typos in the help text.
● Fixed '-v' taking over' -V'.
● Removed the exit condition for 'Advapi32.dll'.
Image