Page 1 of 1

Prevent multiple instances of an application

PostPosted: January 17th, 2010, 8:04 am
by mathgod
I already know how to prevent multiple instance of my own application. However, I am drawing a blank on how to prevent the spawning of a second instance of another application. I know about the taskkill command and scheduling the batch file to run.

I want to detect when "parser.exe" spawns a second instance and kill off that second process.

Re: Prevent multiple instances of an application

PostPosted: January 18th, 2010, 7:46 am
by SaeedShekari
I do the following for the same purpose, Hope this will help you...

Code: Select all
Procedure DoLunch;
Var
  hw: Hwnd;
Begin
  Hw:= FindWindow('YourWindowNameInHere', Nil);
  //Check FindWindow Win API Function for 'YourWindowNameInHere'
  If (HW = 0) Then
  Begin
    //Your application is not running
  End;
End;

Re: Prevent multiple instances of an application

PostPosted: January 19th, 2010, 2:32 am
by mathgod
Thank you. Your solution works well.