判断程序是否正在运行

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 ;

别忘了,Use TlHelp32

转载于:https://www.cnblogs.com/sonicit/archive/2008/06/10/1216604.html

你可能感兴趣的:(判断程序是否正在运行)