Page 1 of 1
Executing one copy of an external application
Posted: Sat Mar 25, 2006 1:59 pm
by Dan Landon
I am trying to execute calc.exe and I only want one copy to be running at a time. I am using WinExec("calc") to execute the program, but I don't want multiple copies. If calc.exe is already running I want to show the running copy and not start a new copy.
Does anyone know the procedure for checking if a copy is running and if so then show it rather than executing another copy?
Dan
Posted: Sat Mar 25, 2006 6:25 pm
by Antonio Linares
Dan,
You may use FindWindow() to first locate the app. Please review this thread:
http://fivetechsoft.com/forums/viewtopi ... dwindow%2A
Posted: Sun Mar 26, 2006 1:13 am
by Dan Landon
I got the code working that finds the window, but I can't seem to get the calc application to come to the foreground. ShowWindow(hWnd) doesn't seem to do it.
Dan
Posted: Sun Mar 26, 2006 8:02 am
by Enrico Maria Giordano
Try SetForegroundWindow() or BringWindowToTop().
EMG
Posted: Sun Mar 26, 2006 8:02 am
by Antonio Linares
Dan,
Please do a MsgInfo( GetWindowText( hWnd ) ) just to be sure it is the calc, before doing ShowWindow( hWnd ).
Posted: Sun Mar 26, 2006 11:52 am
by Dan Landon
BringWindowToTop() worked.
Thanks
Dan