Executing one copy of an external application

Executing one copy of an external application

Postby Dan Landon » Sat Mar 25, 2006 1: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
Dan Landon
 
Posts: 28
Joined: Wed Nov 09, 2005 11:46 am

Postby Antonio Linares » Sat Mar 25, 2006 6: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41312
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Dan Landon » Sun Mar 26, 2006 1: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
Dan Landon
 
Posts: 28
Joined: Wed Nov 09, 2005 11:46 am

Postby Enrico Maria Giordano » Sun Mar 26, 2006 8:02 am

Try SetForegroundWindow() or BringWindowToTop().

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8310
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Antonio Linares » Sun Mar 26, 2006 8: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41312
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Dan Landon » Sun Mar 26, 2006 11:52 am

BringWindowToTop() worked.

Thanks
Dan
Dan Landon
 
Posts: 28
Joined: Wed Nov 09, 2005 11:46 am


Return to FiveMac / FivePhone (iPhone, iPad)

Who is online

Users browsing this forum: No registered users and 4 guests