; 脚本由 Inno Setup 脚本向导 生成!
; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档!
#define MyAppName "examle"
[Setup]
; 注: AppId的值为单独标识该应用程序。
; 不要为其他安装程序使用相同的AppId值。
; (生成新的GUID,点击 工具|在IDE中生成GUID。)
AppId={{5EF80699-C8CA-464E-94A7-0A87A8841A22}}
AppName=example
AppVersion=1.5
;AppVerName=example 1.5
AppPublisher=我的公司
AppPublisherURL=http://www.example.com/
AppSupportURL=http://www.example.com/
AppUpdatesURL=http://www.example.com/
DefaultDirName={pf}\example
DefaultGroupName=example
OutputDir=F:\Test
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
Uninstallable=yes
UninstallDisplayName=卸载 {#MyAppName}
[Languages]
Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1
[Files]
Source: "C:\Users\qinbo\Desktop\GMP\KnowledgeManagement.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\qinbo\Desktop\GMP*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "C:\Users\qinbo\Desktop\GMP\plugins\instsall.bat"; DestDir: "{app}"; Flags: ignoreversion
; 注意: 不要在任何共享系统文件上使用“Flags: ignoreversion”
[Icons]
Name: "{group}\example"; Filename: "{app}\KnowledgeManagement.exe"
Name: "{commondesktop}\example"; Filename: "{app}\KnowledgeManagement.exe"; Tasks: desktopicon
[Run]
Filename: "{app}\KnowledgeManagement.exe"; Description: "{cm:LaunchProgram,example}"; Flags: nowait postinstall skipifsilent
Filename: "C:\Users\qinbo\Desktop\GMP\plugins\instsall.bat"; Flags: nowait
[Registry]
Root: HKLM; Subkey:"Software\Test\example";ValueType:dword;ValueName:config;ValueData:10;Flags:uninsdeletevalue
[Code]
//删除所有配置文件以达到干净卸载的目的
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep = usUninstall then
//if MsgBox('您是否要删除用户配置信息?', mbConfirmation, MB_YESNO) = IDYES then
//删除 {app} 文件夹及其中所有文件
DelTree(ExpandConstant('{app}'), True, True, True);
end;
//把安装位置在安装的时候写进注册表中,更新安装的时候你读取注册表中已保存的路径
procedure InitializeWizard();
var ResultStr: String;
ResultCode: Integer;
begin
if RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall{5EF80699-C8CA-464E-94A7-0A87A8841A22}}_is1', 'UninstallString', ResultStr) then
begin
ResultStr := RemoveQuotes(ResultStr);
Exec(ResultStr, '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
end;
end;
//检查版本号
function GetInstalledVersion(): String;
var
InstalledVersion: String;
begin
InstalledVersion :='';
RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion', 'Installed version', InstalledVersion);
Result := InstalledVersion;
end
;//安装、卸载前检查关闭**进程
var
HasRun:HWND;
function InitializeSetup():Boolean;
begin
//检测运行应用程序
Result := true;
HasRun := FindWindowByWindowName('我的应用');
while HasRun<>0 do
begin
if MsgBox('安装程序检测到你的应用程序正在运行。' #13#13 '您必须先关闭它然后单击“是”继续安装,或按“否”退出!', mbConfirmation, MB_YESNO) = idNO then
begin
Result := false;
HasRun := 0;
end
else
begin
Result := true;
HasRun := FindWindowByWindowName('Gloud Arena');
end;
end;
end;
function InitializeUninstall(): Boolean;
begin
HasRun := FindWindowByWindowName('我的应用');
if HasRun<>0 then
begin
MsgBox('卸载程序检测到你的应用程序正在运行。' #13#13 '请先退出你的应用程序,然后再进行卸载!', mbError, MB_OK);
Result := false;
end
else
Result := true;
end;
[/code]