我能否找到在卸载期间执行事件和部分的实际顺序?例如,UninstallDelete
是否先于usPostUninstall
卸载步骤?
Inno Setup手册中有"安装顺序"的文章,但它看起来更像是编译顺序,而不是执行。
卸载顺序与安装顺序相反,就像手册所说的那样(它实际上是安装顺序,而不是编译顺序)。
这只是因为没有程序的卸载顺序。安装程序将其步骤记录到卸载日志中,卸载程序只是以相反的顺序处理日志,没有任何更改顺序的选项。
事件函数适用于卸载过程如下(仅显示主要卸载步骤):
-
CurUninstallStepChanged(usAppMutexCheck)
-
InitializeUninstallProgressForm
-
CurUninstallStepChanged(usUninstall)
- 处理卸载日志:
-
[UninstallRun]
< - 注册中心条目/gh><
- 图标/gh>文件
- 应用程序目录
-
[UninstallDelete]
-
- 第二次尝试删除目录(例如那些之前不是空的目录)
-
CurUninstallStepChanged(usPostUninstall)
-
CurUninstallStepChanged(usDone)
-
DeinitializeUninstall
我已经在一个简单的安装程序上测试过了:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}My Program
DefaultGroupName=My Program
UninstallDisplayIcon={app}MyProg.exe
OutputDir=.
[Files]
Source: "MyProg.exe"; DestDir: "{app}"
[Icons]
Name: "{group}My Program"; Filename: "{app}MyProg.exe"
[UninstallRun]
FileName: "{app}MyProg.exe"
[UninstallDelete]
Type: files; Name: "{app}test.dat"
[Code]
function InitializeUninstall(): Boolean;
begin
Log('InitializeUninstall');
Result := True;
end;
procedure InitializeUninstallProgressForm;
begin
Log('InitializeUninstallProgressForm');
end;
procedure DeinitializeUninstall;
begin
Log('DeinitializeUninstall');
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
Log('CurUninstallStepChanged + ' + IntToStr(Integer(CurUninstallStep)));
end;
卸载日志是这样的(它不显示所有的步骤):
2015-07-19 10:47:54.845 Log opened. (Time zone: UTC+02:00)
2015-07-19 10:47:54.846 Setup version: Inno Setup version 5.5.5 (u)
2015-07-19 10:47:54.846 Original Uninstall EXE: C:Program Files (x86)My Programunins000.exe
2015-07-19 10:47:54.846 Uninstall DAT: C:Program Files (x86)My Programunins000.dat
2015-07-19 10:47:54.846 Uninstall command line: /SECONDPHASE="C:Program Files (x86)My Programunins000.exe" /FIRSTPHASEWND=$1309D4 /INITPROCWND=$2509E4 /log=b:uninstalluninstall.log
2015-07-19 10:47:54.846 Windows version: 6.3.9600 (NT platform: Yes)
2015-07-19 10:47:54.846 64-bit Windows: Yes
2015-07-19 10:47:54.846 Processor architecture: x64
2015-07-19 10:47:54.846 User privileges: Administrative
2015-07-19 10:47:54.846 64-bit install mode: No
2015-07-19 10:47:54.846 Created temporary directory: C:UsersmartinAppDataLocalTempis-4R498.tmp
2015-07-19 10:47:54.860 InitializeUninstall
2015-07-19 10:47:54.860 Message box (Yes/No):
Are you sure you want to completely remove My Program and all of its components?
2015-07-19 10:47:55.797 User chose Yes.
2015-07-19 10:47:55.797 CurUninstallStepChanged + 0
2015-07-19 10:47:55.802 InitializeUninstallProgressForm
2015-07-19 10:47:55.810 CurUninstallStepChanged + 1
2015-07-19 10:47:55.810 Starting the uninstallation process.
2015-07-19 10:47:55.810 Running Exec filename: C:Program Files (x86)My ProgramMyProg.exe
2015-07-19 10:47:57.111 Process exit code: 0
2015-07-19 10:47:57.143 Deleting file: C:ProgramDataMicrosoftWindowsStart MenuProgramsMy ProgramMy Program.lnk
2015-07-19 10:47:57.144 Deleting directory: C:ProgramDataMicrosoftWindowsStart MenuProgramsMy Program
2015-07-19 10:47:57.144 Deleting file: C:Program Files (x86)My ProgramMyProg.exe
2015-07-19 10:47:57.145 Deleting directory: C:Program Files (x86)My Program
2015-07-19 10:47:57.145 Failed to delete directory (145). Will retry later.
2015-07-19 10:47:57.145 Deleting file: C:Program Files (x86)My Programtest.dat
2015-07-19 10:47:57.145 Deleting Uninstall data files.
2015-07-19 10:47:57.662 Deleting directory: C:Program Files (x86)My Program
2015-07-19 10:47:57.665 Uninstallation process succeeded.
2015-07-19 10:47:57.665 Removed all? Yes
2015-07-19 10:47:57.665 Need to restart Windows? No
2015-07-19 10:47:57.668 CurUninstallStepChanged + 2
2015-07-19 10:47:57.668 Message box (OK):
My Program was successfully removed from your computer.
2015-07-19 10:47:58.342 User chose OK.
2015-07-19 10:47:58.342 CurUninstallStepChanged + 3
2015-07-19 10:47:58.342 DeinitializeUninstall
2015-07-19 10:47:58.343 Log closed.