解决方案 »

  1.   


    function CheckTask(ExeFileName: string): Boolean;
    const
      PROCESS_TERMINATE=$0001;
    var
      ContinueLoop: BOOL;
      FSnapshotHandle: THandle;
      FProcessEntry32: TProcessEntry32; //TLhelp32单元
    begin
      Result := False;
      FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
      FProcessEntry32.dwSize := Sizeof(FProcessEntry32);
      ContinueLoop := Process32First(FSnapshotHandle,FProcessEntry32);
      while integer(ContinueLoop) <> 0 do
      begin
        if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) =UpperCase(ExeFileName))
          or (UpperCase(FProcessEntry32.szExeFile) =UpperCase(ExeFileName))) then
          result := True;
        ContinueLoop := Process32Next(FSnapshotHandle,FProcessEntry32);
      end;
    end;
      

  2.   

    function FindProcess(AFileName:string):boolean;
    var
    hSnapshot:THandle;
    lppe:TProcessEntry32;
    Found:Boolean;
    begin
    Result:=False;
    hSnapshot:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
    lppe.dwSize:=SizeOf(TProcessEntry32);
    Found:=Process32First(hSnapshot,lppe);
    while Found do
    begin
    if((UpperCase(ExtractFileName(lppe.szExeFile))=UpperCase(AFileName))   or   (UpperCase(lppe.szExeFile   )=UpperCase(AFileName)))   then
    begin
    Result:=True;
    end;
    Found:=Process32Next(hSnapshot,lppe);
    end;
    end;枚举进程