BBC BASIC for Windows
Programming >> Communication and Input/Output >> Serial comms: identifying open ports
http://bb4w.conforums.com/index.cgi?board=communication&action=display&num=1425194525

Serial comms: identifying open ports
Post by g3nrw on Mar 1st, 2015, 06:22am

I am still try to resurrect a half-completed project to identify serial ports that have been opened by apps running on a Windows machine.

The desired output will be a listing showing, for each opened port, the name of the app that opened the port. Something like this:
Code:
COM4    C:\Program Files\app\app.exe
COM200  C:\xyz\myapp.exe
CNCA123 C:\abc\anotherapp.exe
 


This is straightforward to do manually using Sysinternals Process Explorer, but I want to do it programmatically in BB4W.

So far in BB4W I have been able to identify the Windows device name for each serial port. For example:
Code:
COM4 = \Device\ProlificSerial0
COM200 = \Device\VSPE_SERIAL200
CNCA123 = \Device\com0com11
 


and in BB4W I can list the running processes on the system, using CreateToolhelp32Snapshot. Problem is, I am missing the necessary WINAPI system call(s) that will let me associate the device names with the processes.

I have spent many hours Googling the Microsoft WINAPI pages and various forums, but have drawn a blank.

Hints anyone?

--
Ian

Re: Serial comms: identifying open ports
Post by AndrewCool on Feb 29th, 2016, 11:28pm

Hi Ian,

Would you be willing to share the BB4W code that produces this output?

COM4 = \Device\ProlificSerial0
COM200 = \Device\VSPE_SERIAL200
CNCA123 = \Device\com0com11

For my purposes that info is just dandy!

TIA,

Andrew