Hi,
I am using innosetup to create installation for my windows application. Before starting installation i need to check whether application is already running or not. I have used the following code, which is not working properly.
const
WM_CLOSE = 16;
Function InitializeSetup : Boolean;
var winHwnd: longint;
retVal : boolean;
strProg: string;
begin
Result := true;
try
strProg := 'myApp.exe';
winHwnd := FindWindowByWindowName(strProg);
Log('winHwnd: ' + inttostr(winHwnd));
if winHwnd <> 0 then
retVal:=postmessage(winHwnd,WM_CLOSE,0,0);
if retVal then begin
MsgBox('Window is not running', mbInformation, MB_OK);
Result := True
end
else begin
MsgBox('Window still open', mbInformation, MB_OK);
Result := False;
end;
except
end;
end;
Here winHwnd is always comes as 0. Please let me know what's wrong with this code.
Thanks, Manju