Inno Setup是一款免费而且开源的打包工具,在这我将我刚打包的一个例子做个记录,用来以后打包时作为参考,Inno setup里用到的脚本是pascal脚本,不是太熟悉,我只是在网上查的资料做的简单使用,打包的实例以及inno setup安装包以及部分参考资料在本文底部有下载连接。
实例:我现在有三个文件,一个exe文件,一个dll文件和一个ini配置文件,同时在有电脑上需要判断安装Microsoft Visual C++ 2005 Runtime运行库,所以需要将这四个文件进行打包,实例安装包启动界面如下:
注:上图中界面中图片在inno setup安装包的根目录下:WizModernImage.bmp和WizModernSmallImage.bmp,自己想要更改图片时直接替换覆盖就行,注意图片的尺寸大小
实例脚本如下:
#define MyAppName "小工具箱" #define MyAppVersion "0.1" #define MyAppPublisher "wanglx" #define MyAppURL "http://blog.csdn.net/wanglx_" #define MyAppExeName "MyOwnSoft.exe" [Setup] ; 注: AppId的值为单独标识该应用程序。 ; 不要为其他安装程序使用相同的AppId值。 ; (生成新的GUID,点击 工具|在IDE中生成GUID。) AppId={{F36DF580-B782-4449-840D-EB33F68C9151} AppName={#MyAppName} AppVersion={#MyAppVersion} ;AppVerName={#MyAppName} {#MyAppVersion} AppPublisher={#MyAppPublisher} AppPublisherURL={#MyAppURL} AppSupportURL={#MyAppURL} AppUpdatesURL={#MyAppURL} DefaultDirName={pf}\{#MyAppName} DefaultGroupName={#MyAppName} OutputDir=E:\baiduyundownload\Demo\LockApp\bin OutputBaseFilename=小工具箱 SetupIconFile=E:\InfoSetup Pack\Cat.ico Compression=lzma SolidCompression=yes [Languages] Name: "chinesesimp"; MessagesFile: "compiler:Default.isl" [Tasks] Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1 Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked [Files] Source: "E:\InfoSetup Pack\MyOwnSoft.exe"; DestDir: "{app}"; Flags: ignoreversion Source: "E:\InfoSetup Pack\LockScreens.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "E:\InfoSetup Pack\MyOwnSoft.exe"; DestDir: "{app}"; Flags: ignoreversion Source: "E:\InfoSetup Pack\wanglxconfig.ini"; DestDir: "{app}"; Flags: ignoreversion Source: "E:\InfoSetup Pack\Microsoft Visual C++ 2005.exe"; DestDir: "{tmp}"; Check: IsRegExsit ; 注意: 不要在任何共享系统文件上使用“Flags: ignoreversion” [Icons] Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}" Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon [Messages] BeveledLabel=Professional [Code] var NeedInstallVC: Boolean; procedure URLLabelOnClick(Sender: TObject); var ErrorCode: Integer; begin ShellExec('open', 'http://blog.csdn.net/wanglx_', '', '', SW_SHOW, ewNoWait, ErrorCode) end; procedure InitializeWizard(); var URLLabel: TNewStaticText; var LabelDate: Tlabel; begin //在安装欢迎界面时添加自己的文字 WizardForm.WelcomeLabel2.Autosize := true; LabelDate := Tlabel.Create(WizardForm); LabelDate.Autosize := true; LabelDate.Caption := '本程序由wanglx制作'#10#13#10#13'大家可以免费使用'#10#13#10#13'CSDN: http://blog.csdn.net/wanglx_'; LabelDate.Parent := WizardForm.WelcomePage; LabelDate.Left := WizardForm.WelcomeLabel2.Left; LabelDate.Top := WizardForm.WelcomeLabel2.Top +WizardForm.WelcomeLabel2.Height +80; //显示网站超链接 URLLabel := TNewStaticText.Create(WizardForm); URLLabel.Top := WizardForm.CancelButton.Top; URLLabel.Left :=WizardForm.ClientWidth - WizardForm.CancelButton.Left - WizardForm.CancelButton.Width; URLLabel.Caption := 'http://blog.csdn.net/wanglx_'; URLLabel.Font.Style := [fsBold, fsUnderline]; URLLabel.Font.Color := clBlue; URLLabel.Cursor := crHand; URLLabel.OnClick := @URLLabelOnClick; URLLabel.Font.Name := '宋体'; URLLabel.Font.Height := ScaleY(-13); URLLabel.Parent := WizardForm; URLLabel.Hint := '点击访问相关网站'; URLLabel.ShowHint := True; end; // 这里,不同版本运行环境对应的GUID不同 function IsRegExsit: Boolean; begin if RegValueExists(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{837b34e3-7c30-493c-8f6a-2b0f04e2912c}', 'Version') // Microsoft Visual C++ 2005 Redistributable X86 [XP/Win7 32位 V8.0.61001] or RegValueExists(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{A49F249F-0C91-497F-86DF-B2585E8E76B7}', 'Version') then begin Result := false; end else begin Result := true; end; end; [Run] Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent Filename: "{tmp}\Microsoft Visual C++ 2005.exe"; Parameters: /q; WorkingDir: {tmp}; Flags: skipifdoesntexist; StatusMsg: "Install Microsoft Visual C++ 2005 Runtime ..."; Check: IsRegExsit [CustomMessages] NameAndVersion=%1 版本 %2 AdditionalIcons=附加图标: CreateDesktopIcon=创建桌面图标(&D) CreateQuickLaunchIcon=创建快速启动栏图标(&Q) ProgramOnTheWeb=%1 网站 UninstallProgram=卸载 %1 LaunchProgram=运行 %1 AssocFileExtension=将 %1 与 %2 文件扩展名关联(&A) AssocingFileExtension=正在将 %1 与 %2 文件扩展名关联...安装包5.0及实例和参考文件:
点击打开链接