function IsExeRunningG(FName:String):Boolean;
// uses Tlhelp32
// ©2002 EITAN GILBOA - URL: http://perso.wanadoo.fr/eitang
var LPPE : TProcessEntry32; H: Thandle;
begin
result := false;
h:=CreateToolhelp32Snapshot(TH32CS_SNAPALL ,0);
Lppe.DwSize:=Sizeof(TProcessEntry32);
if Process32First(h,lppe)
then
Begin;
if UpperCase(ExtractFileName(LPPE.szexefile))=UpperCase(FName) then
result:=true;
while Process32next(h,lppe) do
begin
if UpperCase(ExtractFileName(LPPE.szexefile))=UpperCase(FName) then
result:=true;
end;
End;
Closehandle(h);
end; {IsExeRunning}
procedure TForm14.Button1Click(Sender: TObject);
begin
ShowMessage(BoolToStr(IsExeRunningG('YahooMessenger.exe'),true));
end;
is working, in uses add Tlhelp32,
Cheers,
Claudiu
----- Original Message -----
From: Charlie Chambers
To: [email protected]
Sent: Saturday, February 28, 2009 9:00 PM
Subject: Re: [delphi-en] Process run check
Hi Mauro,
Hope this helps.
{----------------------------------------------------------}
function IsExeRunningG(FName:String):Boolean;
// ©2002 EITAN GILBOA - URL: http://perso.wanadoo.fr/eitang
var LPPE : TProcessEntry32; H: Thandle;
begin
result := false;
h:=CreateToolhelp32Snapshot(TH32CS_SNAPALL ,0);
Lppe.DwSize:=Sizeof(TProcessEntry32);
if Process32First(h,lppe)
then
Begin;
if UpperCase(ExtractFileName(LPPE.szexefile))=UpperCase(FName) then
result:=true;
while Process32next(h,lppe) do
begin
if UpperCase(ExtractFileName(LPPE.szexefile))=UpperCase(FName) then
result:=true;
end;
End;
Closehandle(h);
end; {IsExeRunning}
{----------------------------------------------------------}
Cheers,
Charlie
----- Original Message -----
From: "mauro russo" <[email protected]>
To: "delphi-en" <[email protected]>
Sent: Saturday, February 28, 2009 12:17 PM
Subject: [delphi-en] Process run check
Dear,
how to check if an .exe is in execution?
In practice I would like to be sure that, if a my application A1 faults
and is closed, it is automatically restarted.
I thought to use a secondary very simple deamon application A2 which
checks if A1 is in execution and, if not, launches it by ShelExecute.
Moreover A1 does the same with A2.
Really I would like to use a S.O. resource to make A1 and A2 periodically
"speaking" each other. So, if A1 is running, but hanging, A2 can choose to
Terminate it and restart it.
I believe there is some simplier way to obtain my goal, but I am not expert
about windows API.
Some help?
Regards,
Mauro.
----------
Questa email è stata verificata dal sistema centralizzato antivirus della
UniPlan Software
[Non-text portions of this message have been removed]
------------------------------------
-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [email protected]! Groups Links
__________ Information from ESET NOD32 Antivirus, version of virus signature
database 3895 (20090227) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
[Non-text portions of this message have been removed]