Hi John,
I think that I should explain that the code was not originally dedsigned to test if an instance of the same program was running. IOW, to implement a single instance application. For that, I create a mutex as I described in the Nov. 1998 issue of FoxPro Advisor.
The code originally came into being in FPW. I needed the window handle of a spreadsheet program in order to manipulate it using ShowWindow(). The problem was that FindWindow() requires that the entire title bar text be given and is case sensitive. As one might expect, this is a significant problem with applications with dynamic title bars.
As people will recall, under Win 3.1, if say a FoxPro app was maximized, switching to another application either required that FPW be minimized, or that the user use Alt+Tab to switch to the other application. Using ShowWindow() allowed me to have a command button that could be clicked to maximize the other application.
George
Ubi caritas et amor, deus ibi est