Executing one copy of an external application

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

Executing one copy of an external application

Post 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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

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
Dan Landon
Posts: 28
Joined: Wed Nov 09, 2005 11:46 am

Post 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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

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
Dan Landon
Posts: 28
Joined: Wed Nov 09, 2005 11:46 am

Post by Dan Landon »

BringWindowToTop() worked.

Thanks
Dan
Post Reply