; 脚本用 Inno Setup 脚本向导 生成。
; 查阅文档获取创建 INNO SETUP 脚本文件的详细资料!
#define MyAppName "我的程序"
#define MyAppVersion "1.5"
#define MyAppPublisher "我的公司"
#define MyAppURL "http://www.example.com/"
#define MyAppExeName "MyProg.exe"
[Setup]
; 注意: AppId 的值是唯一识别这个程序的标志。
; 不要在其他程序中使用相同的 AppId 值。
; (在编译器中点击菜单“工具 -> 产生 GUID”可以产生一个新的 GUID)
AppId={{E50FAF95-CBC8-44AC-9E68-A1FA0CF1891B}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={code:GetDirName}
DefaultGroupName={#MyAppName}
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
DirExistsWarning=no
[Languages]
Name: "default"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "IAP\MyProg.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "IAP\IAPdata\DelDParam.ini"; DestDir: "{app}\IAPdata"; Flags: uninsneveruninstall
Source: "IAP\IAPplant\localParam.ini"; DestDir: "{app}\IAPplant"; Flags: uninsneveruninstall
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
[Registry]
Root: HKCU; Subkey: "Software\IAP"; ValueType: string; ValueName: "InstallPath"; ValueData: "{app}"
[Code]
var
FoundOldPath: boolean;
OldPath: string;
NewStaticText1: TNewStaticText;
procedure NewDirEditOnChange(Sender: TObject);
begin
if not FoundOldPath then
NewStaticText1.Caption := ''
else
if WizardForm.DirEdit.Text = OldPath then
NewStaticText1.Caption := '提示:该目录中保存有上次使用后留下的用户配置文件,建议您继续使用该目录。'
else
NewStaticText1.Caption := '提示:在目录 '+ OldPath +' 中保存有上次使用后留下的用户配置文件,建议您将软件安装到该目录。';
end;
procedure CheckOldPath;
var
sDir: string;
begin
FoundOldPath := false;
OldPath := '';
if RegQueryStringValue(HKCU, 'Software\IAP', 'InstallPath', sDir) then
begin
FoundOldPath := true;
OldPath := sDir;
end;
end;
function GetDirName(Param: String): String;
begin
if FoundOldPath then
Result := OldPath
else
Result := ExpandConstant('{sd}\IAP');
end;
function InitializeSetup(): Boolean;
begin
CheckOldPath;
Result:= true;
end;
procedure InitializeWizard();
begin
NewStaticText1 := TNewStaticText.Create(WizardForm);
with NewStaticText1 do
begin
Parent := WizardForm.SelectDirPage;
if FoundOldPath then
Caption := '提示:该目录中保存有上次使用后留下的用户配置文件,建议您继续使用该目录。'
else
Caption := '';
Left := ScaleX(0);
Top := ScaleY(102);
Width := ScaleX(410);
Height := ScaleY(30);
WordWrap:= true;
end;
WizardForm.DirEdit.OnChange := @NewDirEditOnChange;
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep = usPostUninstall then
if MsgBox('您是否要保留用户配置信息?', mbConfirmation, MB_YESNO) = IDNO then
//删除 {app} 文件夹及其中所有文件
begin
DelTree(ExpandConstant('{app}'), True, True, True);
RegDeleteKeyIncludingSubkeys(HKCU, 'Software\IAP');
end;
end;