我想判断c:\abc.exe文件有没有运行,如果没有,就运行它,怎么做

解决方案 »

  1.   

    var
      FH: Integer;
      
      FH := FileOpen('c:\abc.exe',  fmOpenRead +  fmShareExclusive);
      if FH = -1 then ShowMessage('已经在运行');
      FileClose(FH);—————————————————————————————————
    宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
    —————————————————————————————————
      

  2.   

    //
    program CATV;
    Uses
      Windows;  
    var
     Mutex: THandle;
    begin
      Mutex := CreateMutex(nil, true,'CATV');
      if GetLastError <> ERROR_ALREADY_EXISTS then
      begin
        Application.Initialize;
        Application.Title := '有线电视用户关系信息系统';
        Application.CreateForm(TfrmMain, frmMain);
        Application.Run;
      end
      else
        MessageBox(0, '有线电视用户管理信息系统已经正在运行!', '请注意!', 48);
      ReleaseMutex(Mutex);
    end.
      

  3.   

    'c:\abc.exe'是一个外部程序,运行之后是自动缩在右下角的任务栏中,然后按上面的方法做还是不行,明明已经运行了,但是还是判断不到,结果再运行一次