locked Re: JTAlert name


Michael Black
 

Trying to make this bullet proof.
Imagine you start multiple JTAlerts -- then start my app.  You don't have sufficient information to tie each to a specific instance.
I do remember the PID...but that's not sufficient if the user restarts something outside the app while the app is down.
Each command-line invocation must be unique and the only way to do that is with the command line arguments which are different for every other app around.

Mike





On Saturday, November 21, 2020, 02:31:49 PM CST, HamApps Support (VK3AMA) <vk3ama.ham.apps@...> wrote:


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.
>
> Mike

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.