FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveMac / FivePhone (iPhone, iPad) Executing one copy of an external application
Posts: 28
Joined: Wed Nov 09, 2005 11:46 AM
Executing one copy of an external application
Posted: Sat Mar 25, 2006 01:59 PM

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

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Executing one copy of an external application
Posted: Sat Mar 25, 2006 06:25 PM

Dan,

You may use FindWindow() to first locate the app. Please review this thread:

http://fivetechsoft.com/forums/viewtopi ... dwindow%2A

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 28
Joined: Wed Nov 09, 2005 11:46 AM
Executing one copy of an external application
Posted: Sun Mar 26, 2006 01:13 AM

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

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Executing one copy of an external application
Posted: Sun Mar 26, 2006 08:02 AM

Try SetForegroundWindow() or BringWindowToTop().

EMG

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Executing one copy of an external application
Posted: Sun Mar 26, 2006 08:02 AM

Dan,

Please do a MsgInfo( GetWindowText( hWnd ) ) just to be sure it is the calc, before doing ShowWindow( hWnd ).

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 28
Joined: Wed Nov 09, 2005 11:46 AM
Executing one copy of an external application
Posted: Sun Mar 26, 2006 11:52 AM

BringWindowToTop() worked.

Thanks
Dan

Continue the discussion