My follow-up. This is all working great!
Thanks, Paul, for adding these features! They really do help a great deal!
My original purpose is to not allow two instances of a specific program (there are 4 separate programs) unless the user specifically allows it. Each separate program is assigned its own name. This is used as the input to a routine that 'mangles' the name, adding a 5 digit random number. For example, 'CMaster' (a base name) might be turned into 'CMaster61857'. This class name is set as the default class name for all windows I create.
For the main (first) window, I manually set its name to the base name ('CMaster'). The %nc command works fine to override the config_params@() default setting. It is on this base class name that I look for another instance BEFORE I create the first window in my program. Stated another way, I don't create any windows before I go checking for a window with this class name. This lets me look for another instance before I ask the question, and the user can pick whether to allow multiple occurrences or not.
In my first (main) window, I capture and save the handle to the window to be used when terminating the program. This is important. If I were to cycle through all windows with this class name, I would terminate other running instances of this program! Not what is intended!
When the program is ready to be terminated, there is some housekeeping to be completed, but mainly, any open windows should be closed. Because the class name of all windows of this instance of the program are uniquely named (except the first, main window), I can use a loop that finds windows by class name (no caption) and destroys them. The main window is closed specifically by the handle that was saved when it was created.
This works really well.
If I want to add the capability of using the caption of the main window (which contains unique information about the data being operated on) to further refine the condition of multiple occurrences to only those operating on the same data, I can do this as well!