Fórum Como verifico se um programa externo esta em execução #271584
09/03/2005
0
Como verifico se um programa externo esta em execução. Caso não esteja eu champo
Joao_ricardomp
Curtir tópico
+ 0
Responder
Posts
09/03/2005
Cabelo
Utilize estas funções..
function FindProcess( Name : string) : dword;
var
FSnapshotHandle : THandle;
FProcessEntry32 : TProcessEntry32;
ContinueLoop:BOOL;
begin
Result := 0;
FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
FProcessEntry32.dwSize:=Sizeof(FProcessEntry32);
ContinueLoop := Process32First(FSnapshotHandle,FProcessEntry32);
while ContinueLoop do
begin
if Name = FProcessEntry32.szExeFile then
begin
result := FProcessEntry32.th32ProcessID ;
CloseHandle(FSnapshotHandle);
exit;
end;
ContinueLoop := Process32Next(FSnapshotHandle,FProcessEntry32);
end;
CloseHandle(FSnapshotHandle);
end;
function Process32First(hSnapshot: cardinal; var lppe: TProcessEntry32) : bool;
begin
result := false;
if @pProcess32First = nil then if not TestToolhelpFunctions then exit;
result := pProcess32First(hSnapshot,lppe);
end;
function Process32Next(hSnapshot: cardinal; var lppe: TProcessEntry32) : bool;
begin
result := false;
if @pProcess32Next = nil then if not TestToolhelpFunctions then exit;
result := pProcess32Next(hSnapshot,lppe);
end;
espero ter ajudado
function FindProcess( Name : string) : dword;
var
FSnapshotHandle : THandle;
FProcessEntry32 : TProcessEntry32;
ContinueLoop:BOOL;
begin
Result := 0;
FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
FProcessEntry32.dwSize:=Sizeof(FProcessEntry32);
ContinueLoop := Process32First(FSnapshotHandle,FProcessEntry32);
while ContinueLoop do
begin
if Name = FProcessEntry32.szExeFile then
begin
result := FProcessEntry32.th32ProcessID ;
CloseHandle(FSnapshotHandle);
exit;
end;
ContinueLoop := Process32Next(FSnapshotHandle,FProcessEntry32);
end;
CloseHandle(FSnapshotHandle);
end;
function Process32First(hSnapshot: cardinal; var lppe: TProcessEntry32) : bool;
begin
result := false;
if @pProcess32First = nil then if not TestToolhelpFunctions then exit;
result := pProcess32First(hSnapshot,lppe);
end;
function Process32Next(hSnapshot: cardinal; var lppe: TProcessEntry32) : bool;
begin
result := false;
if @pProcess32Next = nil then if not TestToolhelpFunctions then exit;
result := pProcess32Next(hSnapshot,lppe);
end;
espero ter ajudado
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)