概述
我們都知道做客戶端軟體,一般交付給客戶的都是exe的安裝包,那么我們平常開發完成之后,如何把程式進行打包呢,找了下發現Inno Setup是個不錯的選擇,
InnoSetup 是一個免費的 Windows 安裝程式制作軟體,第一次發表是在 1997 年,Inno Setup 今天在功能設定和穩定性上的競爭力可能已經超過一些商業的安裝程式制作軟體,
能做什么
1.支持現在所有正在使用的 Windows 版本: 7, 2008 R2, Vista, XP, 2008,2003, 2000, Me, 98, 95, 和 NT 4.0 (不需要服務包),
2.廣泛支持在 64 位 的 Windows XP and Windows Server2003 版本的作業系統中的 64 位應用程式安裝,支持 x64 和 Itanium 兩個結構,(在 Itanium 結構中,必須在 64 位模式安裝 Service Pack 1,)
3.支持創建單個EXE 格式的安裝程式,使你的程式可以很方便地在網路上發表,同時也支持磁盤延伸,
4.標準的Windows 2000/XP 樣式向導界面,
5.定制安裝型別,例如:完整安裝,最小安裝,自定義安裝,
6.完整的卸載功能,
7.檔案安裝:
包括完全的“壓縮”支持,bzip2 和 7-Zip LZMA 檔案壓縮,安裝程式可以比較檔案版本資訊,替換正在使用的檔案,使用共享檔案計數,注冊DLL/OCX 和型別庫,以及安裝字體,
8.可以在任意地方創建快捷方式,包括開始選單和桌面,
9.創建注冊表 和.INI 條目,
10.在安裝之前、之中或之后可運行其他程式,
11.支持多語言安裝,
12.支持密碼和加密安裝,
13.支持數字簽名 、安裝和卸載,
14.后臺安裝和后臺卸載,
15.Unicode安裝,(Windows 2000/XP 或更高)
16.完整的Pascal 腳本 引擎選項于運行期高級自定義安裝和卸載,
17.全部源代碼公開(Borland Delphi 2.0-5.0 和 2009),
創建安裝程式的方式:腳本
安裝程式用編譯腳本的方式創建,腳本其實就是一個類似.INI 檔案格式的 ASCII 碼文本檔案,(它不象你想象的那么復雜!),Unicode Inno Setup支持 UTF-8 編碼文本檔案,
腳本用一個“.iss”(表示 Inno Setup Script腳本) 的擴展名,腳本控制著安裝程式的所有方面,由它指定哪些檔案將被安裝到什么地方,在哪里創建快捷方式,且被命名為什么,
腳本檔案一般可以用安裝程式編譯器程式內置的編輯器進行編輯,在你撰寫完腳本后,下一個最終步驟就是選擇安裝程式編譯器中的“編譯”,創建完成后,就可以運行根據你腳本編譯的安裝程式了,按默認,這個安裝程式創建在包含腳本檔案目錄下的名為“輸出”目錄中,
如果你想看看它是怎樣作業的,啟動安裝程式編譯器,單擊“檔案 | 打開”,并選擇位于 Inno Setup 安裝目錄下的Examples 子目錄中的一個腳本檔案,(你也可以將這些示例腳本作為你自己撰寫腳本的模板,)
以下是我之前的專案的腳本
; Script generated by the Inno Setup Script Wizard. ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! #define MyAppName "主機助手" #define MyAppVersion "1.1.1.7" #define MyAppPublisher "點擊網路, 技術部." #define MyAppURL "http://yroot.bidns.net/" #define MyAppExeName "主機助手.exe" [Setup] ; NOTE: The value of AppId uniquely identifies this application. ; Do not use the same AppId value in installers for other applications. ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) AppId={{CD9818E0-FEE2-418E-9775-15F50AE2229E} AppName={#MyAppName} AppVersion={#MyAppVersion} ;AppVerName={#MyAppName} {#MyAppVersion} AppPublisher={#MyAppPublisher} AppPublisherURL={#MyAppURL} AppSupportURL={#MyAppURL} AppUpdatesURL={#MyAppURL} DefaultDirName={pf}\ZhugAssistant DisableProgramGroupPage=yes OutputDir=C:\Users\admin\Desktop OutputBaseFilename=主機助手安裝包 SetupIconFile=C:\Users\admin\Documents\Visual Studio 2010\Projects\yroot-10-24\yroot\bin\Debug\images\title.ico Compression=lzma SolidCompression=yes [Languages] Name: "english"; MessagesFile: "compiler:Default.isl" [Tasks] Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: exclusive Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked [Files] Source: "D:\Debug\主機助手.exe"; DestDir: "{app}"; Flags: ignoreversion Source: "D:\Debug\AccessSetup.exe"; DestDir: "{app}"; Flags: ignoreversion Source: "D:\Debug\conf\*"; DestDir: "{app}\conf\"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "D:\Debug\data\*"; DestDir: "{app}\data\"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "D:\Debug\images\*"; DestDir: "{app}\images\"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "D:\Debug\tools\*"; DestDir: "{app}\tools\"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "D:\Debug\CSkin.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "D:\Debug\DiskQuotaTypeLibrary.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "D:\Debug\DMSkin.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "D:\Debug\form_data_path.txt"; DestDir: "{app}"; Flags: ignoreversion Source: "D:\Debug\Interop.ADODB.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "D:\Debug\Interop.ADOX.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "D:\Debug\Interop.FsrmLib.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "D:\Debug\Interop.IISOle.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "D:\Debug\Interop.TaskScheduler.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "D:\Debug\MetroFramework.Design.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "D:\Debug\MetroFramework.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "D:\Debug\MetroFramework.Fonts.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "D:\Debug\Microsoft.Web.Administration.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "D:\Debug\Microsoft.Win32.TaskScheduler.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "D:\Debug\MySql.Data.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "D:\Debug\SimpleUpdater.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "D:\Debug\yroot.vshost.exe"; DestDir: "{app}"; Flags: ignoreversion Source: "D:\Debug\yroot.vshost.exe.config"; DestDir: "{app}"; Flags: ignoreversion Source: "D:\Debug\yroot.vshost.exe.manifest"; DestDir: "{app}"; Flags: ignoreversion Source: "D:\Debug\yroot_beta.vshost.exe"; DestDir: "{app}"; Flags: ignoreversion Source: "D:\Debug\yroot_beta.vshost.exe.config"; DestDir: "{app}"; Flags: ignoreversion Source: "D:\Debug\yroot_beta.vshost.exe.manifest"; DestDir: "{app}"; Flags: ignoreversion Source: "D:\Debug\主機助手.exe"; DestDir: "{app}"; Flags: ignoreversion Source: "D:\Debug\主機助手.exe.config"; DestDir: "{app}"; Flags: ignoreversion Source: "D:\Debug\主機助手.pdb"; DestDir: "{app}"; Flags: ignoreversion ; NOTE: Don't use "Flags: ignoreversion" on any shared system files [Icons] Name: "{commonprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon Name: "{group}\{cm:UninstallProgram,主機助手}"; Filename: "{uninstallexe}" ;[Components] ;Name: Access; Description: "Access支持" ; Types: Full [Messages] ;卸載對話框說明 ConfirmUninstall=您真的想要從電腦中卸載主機助手嗎?%n%n按 [是] 將會洗掉 %1 以及它的組件;%n按 [否] 則讓軟體繼續留在您的電腦上. [Run] Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent [Registry] Root: HKLM ;SubKey:"Software\ZhugAssistant";ValueType:dword;ValueName:config;ValueData:10 ;Flags: uninsdeletekey [code] //init setup function InitializeSetup(): boolean; //var var Istoken: boolean; //avoid setup again begin Istoken := true; if RegValueExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\ZhugAssistant', 'config') then begin MsgBox('程式已安裝,請卸載后再嘗試安裝!',mbConfirmation, MB_OK); Istoken := false; end else begin Istoken := true; end; Result := Istoken; end; //next button function NextButtonClick(CurPageID: Integer): Boolean; //var var ResultCode: Integer; var IsSetup : Boolean; begin IsSetup := true ; case CurPageID of wpReady: begin if not RegValueExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\Classes\CLSID\{6F3DD387-5AF2-492B-BDE2-30FF2F451241}\InprocServer32\12.0.0.0', 'RuntimeVersion') then begin if MsgBox('程式執行需要Access資料庫的支持,是否現在安裝?', mbConfirmation, MB_YESNO) = idYes then begin ExtractTemporaryFile('AccessSetup.exe'); ExtractTemporaryFile('DMSkin.dll'); if not Exec(ExpandConstant('{tmp}\AccessSetup.exe'), '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode) then MsgBox('Access安裝出錯:' #13#13 ' ' + SysErrorMessage(ResultCode) + '.', mbError, MB_OK); end else begin IsSetup := false ; end ; BringToFrontAndRestore(); end; end; end; Result := IsSetup; end;

轉載請註明出處,本文鏈接:https://www.uj5u.com/net/270458.html
標籤:WinForm
下一篇:WinForm 捕獲例外 Application.ThreadException + AppDomain.CurrentDomain.UnhandledException
