欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Inno setup制作程序安装包

程序员文章站 2024-03-09 12:13:41
...
; 脚本由 Inno Setup 脚本向导 生成!
; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档!

#define MyAppName "HCview"
#define MyAppVersion "1.0"
#define MyAppPublisher "hpmont"
#define MyAppURL "http://www.hpmont.com/"
#define MyAppExeName "HCview.exe"

[Setup]
; 注: AppId的值为单独标识该应用程序。
; 不要为其他安装程序使用相同的AppId值。
; (生成新的GUID,点击 工具|在IDE中生成GUID。)
AppId={{6E33B90F-757B-424F-ACFE-557F98081770}
;程序名
AppName={#MyAppName}
;程序版本
AppVersion={#MyAppVersion}
AppVerName={#MyAppName} {#MyAppVersion}
;发布者
AppPublisher={#MyAppPublisher}
;相关链接
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
;默认安装目录
DefaultDirName={pf}\{#MyAppName}
;默认开始菜单名
DefaultGroupName={#MyAppName}
;输出文件名
OutputBaseFilename=setup
;安装图标
SetupIconFile=E:\projects\HCview\HCview工程文件\将软件制作成安装软件\HCview20181018\HCview\hpmont.ico
;卸载图标
Uninstallable=true
UninstallDisplayIcon={app}\uninstall.ico
;压缩相关
Compression=lzma
SolidCompression=yes
;安装后重启,用于刷新注册表
AlwaysRestart=yes

[Languages]
Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1

[Files]
Source: "E:\projects\HCview\HCview工程文件\将软件制作成安装软件\HCview20181018\HCview\bin\Release\HCview.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:\projects\HCview\HCview工程文件\将软件制作成安装软件\HCview20181018\HCview\bin\Release\Config.ini"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:\projects\HCview\HCview工程文件\将软件制作成安装软件\HCview20181018\HCview\bin\Release\HCview.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:\projects\HCview\HCview工程文件\将软件制作成安装软件\HCview20181018\HCview\bin\Release\ICSharpCode.SharpZipLib.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:\projects\HCview\HCview工程文件\将软件制作成安装软件\HCview20181018\HCview\bin\Release\LadInst.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:\projects\HCview\HCview工程文件\将软件制作成安装软件\HCview20181018\HCview\bin\Release\WeifenLuo.WinFormsUI.Docking.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:\projects\HCview\HCview工程文件\将软件制作成安装软件\HCview20181018\HCview\bin\Release\UpdateIcon.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:\projects\HCview\HCview工程文件\将软件制作成安装软件\HCview20181018\HCview\hpmont.ico"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:\projects\HCview\HCview工程文件\将软件制作成安装软件\uninstall.ico"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:\projects\HCview\HCview工程文件\将软件制作成安装软件\HCview20181018\HCview\bin\Release\AppIni\*"; DestDir: "{app}\AppIni"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "E:\projects\HCview\HCview工程文件\将软件制作成安装软件\HCview20181018\HCview\bin\Release\zh-CHS\*"; DestDir: "{app}\zh-CHS"; Flags: ignoreversion recursesubdirs createallsubdirs
; 注意: 不要在任何共享系统文件上使用“Flags: ignoreversion”

;创建开始菜单和桌面快捷方式
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"; IconFilename: "{app}\uninstall.ico"
Name: "{userdesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}\hpmont.ico"

[Messages]
BeveledLabel=HCview  
;卸载对话框说明  
ConfirmUninstall=您真的想要从电脑中卸载HCview吗?%n%n按 [是] 则完全删除 %1 以及它的所有组件;%n按 [否]则让软件继续留在您的电脑上.

[Registry]
Root: HKLM; Subkey: Software\HCview; ValueType: string; ValueName: Installed version; ValueData: '1.0'; Flags: uninsdeletekey
Root: HKCR; Subkey: "HCview"; ValueType: string; ValueData: "hpmont梯形图文件"; Flags: uninsdeletekey
Root: HKCR; Subkey: "HCview\DefaultIcon"; ValueType: string; ValueData: "{app}\hpmont.ico"; Flags: uninsdeletekey
Root: HKCR; Subkey: "HCview\shell\open\command"; ValueType: string; ValueData: "{app}\HCview.exe %1"; Flags: uninsdeletekey
Root: HKCR; Subkey: ".hc"; ValueType: string; ValueData: "HCview"; Flags: uninsdeletekey

;执行脚本
[Code]
function GetInstalledVersion(): string;
var InstalledVersion: string;
begin
  InstalledVersion :='';
  RegQueryStringValue(HKLM, 'Software\HCview', 'Installed version', InstalledVersion);
  Result := InstalledVersion;
end;

function InitializeSetup(): Boolean;
var prevVer: string;
begin
  prevVer := GetInstalledVersion();
  result := true;
  if length(prevVer)>0 then
  begin
    //如果程序已经安装过了
    MsgBox('HCview的' + prevVer + '版本已经安装,请卸载后再安装本程序,安装程序将关闭.', mbError, MB_OK);
    result := false;
  end;
end;

//卸载程序清除注册表信息
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep = usUninstall then
  if MsgBox('您是否要删除注册信息?', mbConfirmation, MB_YESNO) = IDYES then
  begin
  RegDeleteKeyIncludingSubkeys(HKEY_LOCAL_MACHINE, 'Software\HCview');
  RegDeleteKeyIncludingSubkeys(HKEY_CLASSES_ROOT, 'HCview');
  RegDeleteKeyIncludingSubkeys(HKEY_CLASSES_ROOT, '.hc');
  end;
end;           


 

相关标签: 软件安装