B4J Question COM port names


Well-Known Member
Licensed User
I use this
For Each s As String In Serial1.ListPorts
    lvPorts.Items.Add( s )
to enumerate the serial ports that are currently installed.
It only returns COM1, COM3 ... instead of the more useful driver names as displayed in the Device Manager.
Is there a way to obtain the actual driver name like Windows displays in the Device Manager?


Licensed User
Longtime User
I found some code here: https://stackoverflow.com/questions...ort-given-its-comx-name-under-windows-in-java

That requires jna to access. Latest version is available here: https://github.com/java-native-access/jna

You need to download the jna jar and the jna-platform jar and copy them to your additional libraries folder. The java code will only work for windows.

You may need to change the references in the #AdditionalJar declarations in the main module if the jna download is a newer version.

In the attached demo app the GetAll method returns a B4x Map, converted from the Hashmap returned by the java code and seems to contain connected devices, The Get method I left so you could try it, but it only appears to return registered devices and then only if it has a friendly name (which my COM1 doesn't) so I am not sure if it will be useful or not.


  • ComPortFriendly.zip
    2.4 KB · Views: 238
Last edited:
Upvote 0