inno steup 安裝判斷 程序是否執行

2022-07-16 13:30:26 字數 2092 閱讀 8642

1、新增了解除安裝判斷用語

2、新增了安裝程式程序是否存在使用了wmi服務

; 指令碼由 inno setup 指令碼嚮導 生成!

; 有關建立 inno setup 指令碼檔案的詳細資料請查閱幫助文件!

[setup]

; (若要生成新的 guid,可在選單中點選 "工具|生成 guid"。)

defaultdirname=\expert_acquisition_system_v1

disableprogramgrouppage=yes

; 以下行取消注釋,以在非管理安裝模式下執行(僅為當前使用者安裝)。

;privilegesrequired=lowest

defaultgroupname=陝十三2.0

outputbasefilename=陝十三1.0

compression=lzma

solidcompression=yes

wizardstyle=modern

[languages]

name: "chinesesimp"; messagesfile: "compiler:default.isl"

[code]

var fswbemlocator: variant;

fwmiservice : variant;

fwbemobjectset: variant;

begin

result := false;

fswbemlocator := createoleobject('wbemscripting.swbemlocator');

fwmiservice := fswbemlocator.connectserver('', 'root\cimv2', '', '');

fwbemobjectset := fwmiservice.execquery(format('select name from win32_process where name="%s"',[filename]));

result := (fwbemobjectset.count > 0);

fwbemobjectset := unassigned;

fwmiservice := unassigned;

fswbemlocator := unassigned;

end;

function initializesetup(): boolean;

begin

if result then

begin

msgbox('當前系統中已經存在資料庫,請先關閉程式後再重試! ', mberror, mb_ok);

result:=false;

endelse

begin

result := true;

end;

end;

function initializeuninstall(): boolean;

var text: string;

begin

result := (msgbox('當前解除安裝會解除安裝所關聯的資料庫資料以及程式,如繼續解除安裝請按【是】放棄請按【否】', mbconfirmation, mb_yesno) = idyes);

end;

[tasks]

name: "desktopicon"; description: ""; groupdescription: ""; flags: checkablealone

;name: "quicklaunchicon"; description: ""; groupdescription: ""; flags: unchecked

[files]

; 注意: 不要在任何共享系統檔案上使用「flags: ignoreversion」

[icons]

//開始選單快捷方式

//桌面快捷方式

//開始選單解除安裝程式

[ini]

;修改資料庫配置檔案

[run]

[uninstallrun]

[uninstalldelete]

Delphi程序判斷

program project2 uses windows tlhelp32 function findprocess afilename string boolean varhsnapshot thandle lppe tprocessentry32 found boolean begin res...

判斷程序時候執行。

include include include include include include define sync lock usr local nagios var rw nagioslogd.pid define sync lock a usr local nagios var rw nag...

判斷子程序是否存在

if kill pidt,0 0 child process has dead.else child alive 前提條件是,父程序已經處理了sigchld.否則,此檢測方法將失效 unix 環境高階程式設計 的解釋為 kill pid t pid,int signo posix將編號為0的訊號定義...