gpt4 book ai didi

installation - 创新设置: Close installer wizard if file exists in the program's folder

转载 作者:行者123 更新时间:2023-12-03 04:16:00 24 4
gpt4 key购买 nike

我正在尝试创建一个演示安装程序,如果它在程序文件夹中检测到文件close.txt,则会关闭向导或中止安装。

我正在运行一个计划任务,该任务会在两天后自动卸载该应用程序。初始安装时,close.txt 文件会安装在程序文件夹中,然后自动卸载后,close.txt 文件会保留在程序文件夹中。我希望当您重新运行安装程序时,它会检查此文件,如果发现则关闭向导或中止安装。我是这方面的新手,我认为它可以在代码部分中完成,但我不确定。

任何帮助或代码片段将不胜感激,谢谢!

最佳答案

测试 InitializeSetup event function 中的文件是否存在并返回False(如果存在)。

[Setup]
DefaultDirName={autopf}\My Program
[Code]
function WasMyProgramEverInstalled: Boolean;
begin
Result := FileExists('{#SetupSetting("DefaultDirName")}\close.txt');
end;

function InitializeSetup: Boolean;
begin
Result := True;
if WasMyProgramEverInstalled then
begin
MsgBox('Some message', mbError, MB_OK); { Optionally }
Result := False;
end;
end;

请注意,如果安装程序允许自定义安装路径,则在卸载后重新运行安装时您将不会知道它。所以这行不通。

关于installation - 创新设置: Close installer wizard if file exists in the program's folder,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28643130/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com