环境:Win7 x64
目标:安装程序包,不选择路径,不选择开始菜单文件夹名
代码:
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "AppName"
#define MyAppVersion "1.0"
#define MyAppPublisher "Company"
#define MyAppURL "http://www.12345678.com/"
[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={{5FA1FFC3-B175-4E6C-8918-5103B118AB22}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
;DefaultDirName={pf}\{#MyAppName}
;DefaultGroupName={#MyAppName}
;不需要选择路径
CreateAppDir=no
AllowNoIcons=yes
OutputDir=E:
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
;开始菜单中的程序组名称不用指定
DisableProgramGroupPage=yes
DefaultGroupName={#MyAppName}
[Languages]
Name: "chinesesimplified"; MessagesFile: "compiler:Languages\ChineseSimplified.isl"
[Files]
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}";
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}";
[Code]
function InitializeSetup(): Boolean;
var
Env_Path:String;
begin
Env_Path := GetEnv('ENV_PATH')
if Env_Path = '' then
begin
MsgBox('路径不存在,退出安装程序!', mbInformation, MB_OK);
Result :=false
end
else
Result :=true
end;
;必须带参数 Param:String,否则报错
function GetPath(Param: String):String;
var
Env_Path:String;
begin
Env_Path := GetEnv('ENV_PATH')
Result :=Env_Path
end;