判断程序是否正在运行
function IsRuning(const AObjectName: string): Boolean;{AObjectName='aaa.exe'}
var
lppe : TProcessEntry32;
sshandle: Thandle;
found: boolean;
begin
Result := False;
sshandle := CreateToolhelp32Snapshot(TH32CS_SNAPALL,0);
found := Process32First(sshandle,lppe);
while found do
begin
if LowerCase(lppe.szExeFile) = LowerCase(AObjectName) then
begin
Result := True;
Exit;
end;
found := Process32Next(sshandle, lppe);
end;
end;
var
lppe : TProcessEntry32;
sshandle: Thandle;
found: boolean;
begin
Result := False;
sshandle := CreateToolhelp32Snapshot(TH32CS_SNAPALL,0);
found := Process32First(sshandle,lppe);
while found do
begin
if LowerCase(lppe.szExeFile) = LowerCase(AObjectName) then
begin
Result := True;
Exit;
end;
found := Process32Next(sshandle, lppe);
end;
end;
别忘了,Use TlHelp32。