我为许多“标准”安装程序使用Inno安装程序,但是为了完成这个任务,我需要提取一堆临时文件,运行其中的一个,然后删除它们并退出安装程序(实际上没有安装任何东西)。
基本上,我正在寻找一个没有“安装器”的自解压程序,并追求最好的用户体验与inno设置。
我有以下代码,几乎可以很好地工作:
[Files]
Source: "dist\*"; Flags: recursesubdirs ignoreversion dontcopy;
[Code]
function InitializeSetup(): Boolean;
var
ResultCode: Integer;
begin
Result := True;
MsgBox('Please wait a minute or two...', mbInformation, MB_OK);
ExtractTemporaryFiles('{tmp}\*');
Exec(ExpandConstant('{tmp}\MyScript.exe'), '', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Abort();
end;
问题是,我在这里能做的最好的事情就是显示一个消息框“请等待一两分钟...”,用户点击Ok,然后等待,因为屏幕上看起来什么都没有发生,然后MyScript.exe
启动。
我想要的是一个向导页面,上面写着“正在提取临时文件,请稍候...”有一个npbstMarquee
风格的进度条,一旦文件被解压并启动我的脚本,它就会消失。
我不认为有一种方法可以告诉Inno Setup在ExtractTemporaryFiles()
运行时显示进度条(这将是理想的),并且将其放入一个自定义向导页面中让我感到困惑。
发布于 2018-08-23 15:06:34
将文件“安装”到{tmp}
,而不是使用installed);
{tmp}
提取到{tmp}
的文件(或者在文件被installed);
ExtractTemporaryFiles
;
no
;Uninstallable
>C20CreateAppDir
>之后,使用AfterInstall
参数或CurStepChanged
来触发Uninstallable
脚本代码,以编辑过于以安装程序为中心的向导文本。<代码>H221<代码>F222[Setup]
Uninstallable=no
CreateAppDir=no
[Files]
Source: "dist\*"; DestDir: {tmp}; Flags: recursesubdirs
[Run]
FileName: "{tmp}\MyScript.exe"
备注:
{tmp}
文件夹被自动删除;当安装到新的空文件夹时,ignoreversion
标志。一个相关的问题:Inno Setup installer that only runs a set of embedded installers
有关文字问题的答案,请参阅Inno setup: ExtractTemporaryFile causes wizard freeze。或者关于这个主题的一个更一般的问题:Inno Setup: How to modify long running script so it will not freeze GUI?
发布于 2018-08-13 13:36:56
看起来ExtractTemporaryFiles()实际上锁定了UI直到它完成,所以没有办法在这里得到一个进度条(或选框)动画。
而且,当ExtractTemporaryFiles()正在运行时,在屏幕上获取消息也是很困难的。我是这样解决的:
const
WM_SYSCOMMAND = 274;
SC_MINIMIZE = $F020;
//-------------------------------------------------------------------
procedure MinimizeButtonClick();
begin
PostMessage(WizardForm.Handle, WM_SYSCOMMAND, SC_MINIMIZE, 0);
end;
//-------------------------------------------------------------------
procedure CurPageChanged(CurPageID: Integer);
var
ResultCode: Integer;
begin
if CurPageID = wpPreparing then
begin
MinimizeButtonClick();
Exec(ExpandConstant('{tmp}\MyScript.exe'), '', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
end;
end;
//-------------------------------------------------------------------
function NextButtonClick(CurPageID: Integer): Boolean;
var
ProgressPage: TOutputProgressWizardPage;
begin
if CurPageID = wpReady then
begin
ProgressPage := CreateOutputProgressPage('Preparing files...', '');
ProgressPage.Show;
try
ProgressPage.Msg1Label.Caption := 'This process can take several minutes; please wait ...';
ExtractTemporaryFiles('{tmp}\*');
finally
ProgressPage.Hide;
end;
end;
Result := True;
end;
//-------------------------------------------------------------------
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssInstall then
begin
//MinimizeButtonClick() is called here as the Wizard flashes up for a second
// and minimizing it makes that 1/2 a second instead...
MinimizeButtonClick();
Abort();
end;
end;
然后,我使用Messages部分更改了"Ready“页面上的文本以适应需要。
结果是:
https://stackoverflow.com/questions/51814408
复制相似问题