日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

一个比较完整的Inno Setup 安装脚本

發(fā)布時(shí)間:2025/3/15 编程问答 44 豆豆
生活随笔 收集整理的這篇文章主要介紹了 一个比较完整的Inno Setup 安装脚本 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
從網(wǎng)上搜索來(lái)的,增加了對(duì)ini文件設(shè)置的功能,一個(gè)安裝包常用的功能都具備了。 ?
?[Setup]
; 注: AppId的值為單獨(dú)標(biāo)識(shí)該應(yīng)用程序。
; 不要為其他安裝程序使用相同的AppId值。
; (生成新的GUID,點(diǎn)擊 工具|在IDE中生成GUID。)
AppId={{A9861883-31C5-4324-BD9A-DC3271EEB675}
;程序名
AppName=ISsample
;版本號(hào)
AppVerName=ISsample 1.0.0.0
;發(fā)布者名
AppPublisher=Hkiss
;相關(guān)連接
AppPublisherURL=http://zwkufo.blog.163.com
AppSupportURL=http://zwkufo.blog.163.com
AppUpdatesURL=http://zwkufo.blog.163.com
;默認(rèn)安裝目錄
DefaultDirName={pf}\ISsample
;默認(rèn)開(kāi)始菜單名
DefaultGroupName=ISsample
;是否打開(kāi)->可選安裝開(kāi)始菜單項(xiàng)
;AllowNoIcons=yes
;安裝協(xié)議
;LicenseFile=C:\Example\原始文件\agreement.txt
;安裝前查看的文本文件
;InfoBeforeFile=C:\Example\原始文件\Setup_New.txt
;安裝后查看文本文件
;InfoAfterFile=C:\Example\原始文件\Setup_Old.txt
;輸出文件夾
OutputDir=C:\Example\InnoSetup\out
;輸出文件名
OutputBaseFilename=setup
;安裝圖標(biāo)
SetupIconFile=C:\Example\原始文件\title.ico
;安裝需要輸入密碼
;Password=123
;Encryption=yes


;壓縮相關(guān)
Compression=lzma
SolidCompression=yes


;可以讓用戶忽略選擇語(yǔ)言相關(guān)
ShowLanguageDialog = yes
;備注版本信息
VersionInfoCompany=HTTP://www.Hkiss.COM
VersionInfoDescription=ISsample 漢化增強(qiáng)版
VersionInfoVersion=1.0.0.0
VersionInfoCopyright=Copyright (C) 2007-2008 Hkiss


;制作選擇語(yǔ)言
[Languages]
Name: "chs"; MessagesFile: "compiler:Default.isl" ;LicenSeFile :"C:\Example\原始文件\chs\agreement.txt"
Name: "en"; MessagesFile: "compiler:Languages\English.isl";LicenSeFile :"C:\Example\原始文件\en\agreement.txt"


;用戶定制任務(wù)
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Name: "Tasks_1" ; Description:"用戶自定義任務(wù)1"; Flags: unchecked
Name: "Tasks_2" ; Description:"用戶自定義任務(wù)2"; Flags: unchecked
;選擇了組件才會(huì)出現(xiàn)的定制任務(wù)
Name: "Tasks_3" ; Description:"用戶自定義任務(wù)3";Components: c1 ; Flags: unchecked


;文件安裝
[Files]
;多語(yǔ)言安裝環(huán)境設(shè)置 ? ?公共參數(shù)Languages 來(lái)設(shè)置
Source: "C:\Example\原始文件\enfile.txt"; DestDir: "{app}"; Languages: en ; Flags: ignoreversion
Source: "C:\Example\原始文件\chsfile.txt"; DestDir: "{app}"; Languages: chs ; Flags: ignoreversion
;用戶自定義任務(wù) Tasks
Source: "C:\Example\原始文件\Tasks\tasks_1.txt"; DestDir: "{app}\Tasks"; Flags: ignoreversion ;Tasks : Tasks_1
Source: "C:\Example\原始文件\Tasks\tasks_2.txt"; DestDir: "{app}\Tasks"; Flags: ignoreversion ;Tasks :Tasks_2
Source: "C:\Example\原始文件\Tasks\tasks_Components.txt"; DestDir: "{app}\Tasks"; Flags: ignoreversion ;Tasks :Tasks_2
;用戶定義組件安裝
Source: "C:\Example\原始文件\Components\Components_1.txt"; DestDir: "{app}\Components"; Flags: ignoreversion ; Components: a1;
Source: "C:\Example\原始文件\Components\Components_2.txt"; DestDir: "{app}\Components"; Flags: ignoreversion ; Components: a2;
Source: "C:\Example\原始文件\Components\Components_3.txt"; DestDir: "{app}\Components"; Flags: ignoreversion ; Components: a3;
Source: "C:\Example\原始文件\Components\Components_4.txt"; DestDir: "{app}\Components"; Flags: ignoreversion ; Components: a1 a2 a3;


;用戶注冊(cè)自定義Dll文件 ? ? ?regserver 注冊(cè) noregerror 不顯示錯(cuò)誤信息
Source: "C:\Example\原始文件\jmail.dll"; DestDir: "{app}"; Flags: ignoreversion regserver
;添加自述文件
Source: "C:\Example\原始文件\ISsample.txt"; DestDir: "{app}"; Flags: ignoreversion
;添加一個(gè)文件到緩存文件夾{Tmp} deleteafterinstall 安裝后刪除
Source: "C:\Example\原始文件\test.exe"; DestDir: "{tmp}"; Flags: ignoreversion deleteafterinstall


Source: "C:\Example\原始文件\ISsample.chm"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Example\原始文件\ISsample.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Example\原始文件\ISsample.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Example\原始文件\ISsample.ini"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Example\原始文件\ISsample.rar"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Example\原始文件\ISsample_sys.dll"; DestDir: "{win}\System32"; Flags: ignoreversion
Source: "C:\Example\原始文件\log\*"; DestDir: "{app}\log"; Flags: ignoreversion recursesubdirs createallsubdirs
; 注意: 不要在任何共享系統(tǒng)文件上使用“Flags: ignoreversion”
;安裝類型設(shè)置
[Types]
Name: Full ;Description:"完全安裝"; Flags: iscustom
Name: Compact ;Description:"簡(jiǎn)潔安裝";
Name: Custom; Description:"自定義安裝";
;組件安裝
[Components]
Name: c1; Description: "自定義任務(wù)3" ; Types: Full
Name: a1; Description: "安裝Components_1"; Types: Full Compact Custom ;
Name: a2; Description: "安裝Components_2"; Types : Full ? Compact
Name: a3; Description: "安裝Components_3"; Types : Full


;開(kāi)始菜單,桌面快捷方式
[Icons]
Name: "{group}\ISsample"; Filename: "{app}\ISsample.exe"
Name: "{group}\{cm:ProgramOnTheWeb,ISsample}"; Filename: "http://zwkufo.blog.163.com"
Name: "{group}\{cm:UninstallProgram,ISsample}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\ISsample"; Filename: "{app}\ISsample.exe"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\ISsample"; Filename: "{app}\ISsample.exe"; Tasks: quicklaunchicon
;添加一個(gè)幫助文擋
Name: {group}\ISsample 1.0.0.0 幫助文檔;Filename: {app}\ISsample.chm


;用來(lái)在程序安裝完成后 在安裝程序顯示最終對(duì)話框之前執(zhí)行程序 常用與運(yùn)行主程序 顯示自述文件 刪除臨時(shí)文件
[Run]
Filename: "{app}\ISsample.exe"; Description: "{cm:LaunchProgram,ISsample}"; Flags: nowait postinstall skipifsilent
Filename: "{app}\ISsample.txt"; Description: "查看顯示自述文件"; Flags: postinstall skipifsilent shellexec


;更改顯示在程序中顯示的消息文本
[Messages]
BeveledLabel=HKiss科技
;卸載對(duì)話框說(shuō)明
ConfirmUninstall=您真的想要從電腦中卸載ISsample嗎?%n%n按 [是] 則完全刪除 %1 以及它的所有組件;%n按 [否]則讓軟件繼續(xù)留在您的電腦上.
;定義解壓說(shuō)明
;StatusExtractFiles=解壓并復(fù)制主程序文件及相關(guān)庫(kù)文件...


;用于在用戶系統(tǒng)中創(chuàng)建,修改或刪除ini文件健值
[INI]
Filename: "{app}\cfg.ini"; Section: "Startup Options"; Flags: uninsdeletesection
Filename: "{app}\cfg.ini"; Section: "Startup Options"; Key: "server ip"; String: "127.0.0.1"
Filename: "{app}\cfg.ini"; Section: "Startup Options"; Key: "server port"; String: "8080"


;用于在用戶系統(tǒng)中創(chuàng)建,修改或刪除注冊(cè)表健值
[Registry]
Root: HKLM ;SubKey:"Software\ISsample";ValueType:dword;ValueName:config;ValueData:10 ;Flags:uninsdeletevalue
;在執(zhí)行腳本
[code]
//全局變量
var MyProgChecked: Boolean;


//判斷程序是否存在
//初始華程序事件
function InitializeSetup(): boolean;
var Isbl: boolean; ? ? ? ? //聲明變量
var Isstr: string;
begin ? ? ? //開(kāi)始
Isbl := true; ? ? ? ? ? ? //變量賦值
Isstr := '歡迎';
if RegValueExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\ISsample', 'config') then
begin
? ? MsgBox('已安裝過(guò),請(qǐng)先卸載在安裝',mbConfirmation, MB_OK);
? ? isbl := false;
end else
begin
? ?//MsgBox('無(wú)值',mbConfirmation, MB_OK);
? ? ?isbl := true;
end;


//下面是個(gè)麻煩的 條件語(yǔ)句 end else 注意
//if MsgBox(Isstr, mbConfirmation, MB_OKCANCEL) = IDOK then
//begin
// isbl := true;
// MsgBox('執(zhí)行了', mbConfirmation, MB_OK);
//end else
//begin
// isbl := false;
//MsgBox('執(zhí)行了', mbConfirmation, MB_OK);
//end;


Result := Isbl;
end; ? ? ? //結(jié)束


procedure CurStepChanged(CurStep: TSetupStep);
var Isstr :string;
begin
if CurStep=ssInstall then ? ? ? //實(shí)際安裝前調(diào)用
begin
? ? //MsgBox('CurStepChanged:實(shí)際安裝前調(diào)用', mbConfirmation, MB_OKCANCEL); ? ? ? ? ? //安裝完成后調(diào)用
end;
if CurStep=ssPostInstall then
begin
? ? Isstr := ExpandConstant('{tmp}\tmp.rar');
// ? ?if FileExists(Isstr) then
// ? ?begin
// ? ? ?MsgBox('文件存在',mbConfirmation, MB_OK);
// ? ?end else
// ? ?begin
// ? ? ?MsgBox('文件不存在',mbConfirmation, MB_OK);
// ? ?end;
? ?// MsgBox('CurStepChanged:實(shí)際安裝后調(diào)用', mbConfirmation, MB_OKCANCEL);
end;
end;


//下一步 按鈕按鈕 事件
function NextButtonClick(CurPageID: Integer): Boolean;
var ResultCode: Integer;
var IsSetup : Boolean;
begin
IsSetup := true ;
case CurPageID of
? ? wpSelectDir:
? ? ? ?MsgBox('NextButtonClick:' #13#13 'You selected: ''' + WizardDirValue + '''.', mbInformation, MB_OK); ? //WizardDirValue路徑
? ? wpSelectProgramGroup:
? ? ? ?MsgBox('NextButtonClick:' #13#13 'You selected: ''' + WizardGroupValue + '''.', mbInformation, MB_OK); //開(kāi)始菜單名
? ? wpReady:
? ? ? begin
? ? ? ?if not RegValueExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\Test', 'config') then ? begin
? ? ? ? ? if MsgBox('程序執(zhí)行需要Test.ext,是否安裝!', mbConfirmation, MB_YESNO) = idYes then begin
? ? ? ? ? ?ExtractTemporaryFile('test.exe');
? ? ? ? ? ? if not Exec(ExpandConstant('{tmp}\test.exe'), '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode) then
? ? ? ? ? ? ? MsgBox('Test.exe出錯(cuò):' #13#13 ' ' + SysErrorMessage(ResultCode) + '.', mbError, MB_OK);
? ? ? ? ? end else begin
? ? ? ? ? ? ? ? IsSetup := false ;
? ? ? ? ? end ;
? ? ? ? ? BringToFrontAndRestore();
? ? ? ? end;
? ? ? end;
end;
Result := IsSetup;
end;

總結(jié)

以上是生活随笔為你收集整理的一个比较完整的Inno Setup 安装脚本的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。