[Code]
//#############################IsNotProcessRun函數###################################
// 自定義函數,判斷軟件是否運行,參數爲需要判斷的軟件的exe名稱
//系統運行strExeName這個exe,返回真,否則返回false
function IsNotProcessRun(strExeName: String): Boolean;
// 變量定義
var ErrorCode: Integer;
var bRes: Boolean;
var strFileContent: AnsiString;
var strTmpPath: String; // 臨時目錄
var strTmpFile: String; // 臨時文件,保存查找軟件數據結果
var strCmdFind: String; // 查找軟件命令
begin
strTmpPath := GetTempDir();
strTmpFile := Format('%sfindSoftRes.txt', [strTmpPath]);
strCmdFind := Format('/c tasklist /nh|find /c /i "%s" > "%s"', [strExeName, strTmpFile]);
bRes := ShellExec('open', ExpandConstant('{cmd}'), strCmdFind, '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
bRes := LoadStringFromFile(strTmpFile, strFileContent);
strFileContent := Trim(strFileContent);
if StrToInt(strFileContent) > 0 then begin
result:=true;
end else result:=false;
end;
//#############################IsNotProcessRun函數###################################
procedure InitializeWizard();
begin
if IsNotProcessRun('httpd.exe') then begin
MsgBox('httpd正在運行', mbInformation, MB_OK);
end else
MsgBox('httpd沒有運行', mbInformation, MB_OK);
end;