Inno Setup - Check if specific exe is running.

Hi.
I have inno setup script(in pascal), and I need to check before installation, if an application is running or not.
The problem is, that:
a) I can not use Mutex, because in my application mutex is created with name + version.
Inno Setup doesn't know particular version of the previously installed programm.
b) I can not use something like IsModuleLoaded('myapp.exe'), because
there could be two different programms with same exe name, but in different folders.
And setup must allow to install to folder A, then the program from folder B\myapp.exe is running.
Any help would be highly appreciated!
P.S Sorry for my english
SpringMVCAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mirtheilSoftware DeveloperCommented:
You could use something like FindWindowByWindowName and then issue a SendMessage with a WM_QUIT to close the application (or just abort the install after displaying a message.  Something like:

function InitializeSetup(): Boolean;
const 
   WM_QUIT = 18;
var 
   winHwnd: longint;
   retVal : boolean;
   strProg: string;
begin
 result:=true;
 try
   strProg := 'MyApplication.exe';
   winHwnd := FindWindowByWindowName(strProg);
   if winHwnd <> 0 then
     begin
      //retVal:=postmessage(winHwnd,WM_QUIT,0,0);
      //or
      //Display Message Box saying application is running
      // and close it, then exit setup by setting:
      //result:=false;      
 except
 end;
end;

Open in new window

0
SpringMVCAuthor Commented:
That's certainly helpful. But if program changes title(and that's my case) during the work - this method won't be working :(
0
gskoczylasSenior Software DeveloperCommented:
You can create additional mutex in your application. Mutex's name should be constant (without Version). Then you can use this mutex in the InnoSetup's script.
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

SpringMVCAuthor Commented:
If I create a mutex, it would be impossible to run two same programs from two different folders.

I am currently searching for a solution, which checks running processes and checks their execution path. So if inno setup installs to "program files/A"
I need to check if a process "prog.exe" exists and if it exists, if it's execution path is "program files/A".
0
gskoczylasSenior Software DeveloperCommented:
So you can create Mutex with some constant name + folder's name.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SpringMVCAuthor Commented:
Hm.. That's also an option :) I'll consider that. Tnx
0
SpringMVCAuthor Commented:
Good solution.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Pascal

From novice to tech pro — start learning today.