locked Re: JTAlert name

HamApps Support (VK3AMA)

On 22/11/2020 5:59 am, Michael Black via groups.io wrote:
But I want the distinction to last over a restart of my app too...and the PID won't do that.
The PID isn't a guaranteed association to any specific named instance
Only thing I have to work with is Window names which I'm not particular fond of relying on that as it's app-specific.

Why not just enumerate the already running processes when you program starts to get the current PIDs (and the process names, main window Hwnd, command-line, etc) for the applications your interested in managing.

Relying on a unique name passed in the command-line for an application instance will be problematic. While it will work with the current JTAlert, many other applications will not support some arbitrarily assigned command-line parameter and will error if an unsupported param is detected.

If your program is generic in nature designed to manage the startup/closing of arbitrary user-defined applications you need to avoid application specific hacks like a "/name=xxx" param.

If you need to track previously started applications across your program restarts you would need to persist some data like a PID that was assigned when your first started that application.

You have everything you need to uniquely identify running applications through the process name, its command-line, window hwnd and PID.

Relying on the command-line only is insufficient, you need to record the State of any application you start so that you can locate it again when your program is restarted. What you include in the State object will likely need to be the PID, Main window Hwnd and command-line if you want to ensure the uniqueness of the running process.

de Laurie VK3AMA

Join Support@HamApps.groups.io to automatically receive all group messages.