Inno Setup 简单安装脚本

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "XXX软件"
#define MyAppVersion " 1.1.0"
#define MyAppPublisher "XXX有限公司"
#define MyAppURL "http://www.xxx.com/"
#define MyAppExeName "XXX软件.exe"
;MySourcePath 程序所在的文件夹路径
#define MySourcePath "D:\Projects\XXX软件\bin\Release"  

[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={{B9FB449D-761A-4A35-B874-807E55DBCDD7}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
;DefaultDirName={pf}\{#MyAppName}      默认的安装路径 C:\Program Files
DefaultDirName =D:\XXX软件\
;DisableProgramGroupPage 如果该项设置为 yes, 安装程序将不会显示“选择程序组”向导页。在这种情况下,它将使用由 [Setup] 段的 DefaultGroupName 关键字指定的组名,或者“(Default)”如果没有指定组名的话
DisableProgramGroupPage=yes
;UsePreviousAppDir 是 yes (默认值)并且安装程序发现已经安装了一个相同应用程序的早期版本,它将用先前选择的目录代替默认的目录名称
UsePreviousAppDir=yes
OutputDir=D:\Inno Out Exe
;DisableDirPage 有效值: yes 或 no 默认值: no 说明: 如果该项设置为 yes, 安装程序将不会显示“选择目标文件夹”向导页。在这种情况下,它将始终使用默认的目录名。
DisableDirPage=no
OutputBaseFilename=XXX软件_Ver{#MyAppVersion}
Compression=lzma
SolidCompression=yes
;在控制面板中的显示的卸载信息
Uninstallable=yes
UninstallDisplayName={#MyAppName}{#MyAppVersion}
UninstallDisplayIcon ={#MySourcePath}\ico\Uninstall.ico
;开始菜单中文件夹的名字 , 默认的为Default
DefaultGroupName={#MyAppName}


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

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

[Files]
Source: "{#MySourcePath}\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#MySourcePath}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files  {#MyAppName}

[Icons]
Name: "{group}\{cm:UninstallProgram, }"; Filename: "{uninstallexe}"
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

[Files]
Source: "{#MySourcePath}\psvince.dll"; Flags: dontcopy noencryption

[code]

// 安装时判断程序是否正在运行
function IsModuleLoaded(modulename: AnsiString ):  Boolean;
external 'IsModuleLoaded@files:psvince.dll stdcall';
function InitializeSetup():boolean;
var
   IsAppRunning: boolean;
begin
    Result := true;
   begin
    Result:= true;//安装程序继续
    IsAppRunning:= IsModuleLoaded('{#MyAppExeName}');
    while IsAppRunning do
       begin
        if MsgBox('安装程序检测到 {#MyAppExeName} 正在运行!' #13#13 '您必须先关闭它然后单击“确定”继续安装,否则按“取消”退出!', mbConfirmation, MB_OKCANCEL) = IDOK then
         begin
         IsAppRunning:= IsModuleLoaded('{#MyAppExeName}')
         Result:= true;
         end else begin
         IsAppRunning:= false;
         Result:= false; //安装程序退出
         Exit;
         end;
       end;
     end;
end;



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值