想要检查目录中是否有1个文件,如果不是,请重新安装,执行消息并停止程序。靠近它的代码,但当我添加消息时,它重复4次仍然安装!你或任何人可以纠正我正在做的事吗非常感谢迈克尔
#define MyAppName "Secretary Assistant"
#define MyAppVersion "3.74"
#define MyAppPublisher ""
[Setup]
AppId={{807EB06A-3962-4AF0-967B-D14B0FEF4E9C}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppPublisher={#MyAppPublisher}
DefaultDirName=C:\Users\{username}\Google Drive\Congregation
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
OutputBaseFilename=Secretary Assistant 3.74 Setup
Compression=lzma
SolidCompression=yes
UsePreviousAppDir=no
DirExistsWarning=No
DisableWelcomePage=yes
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Files]
Source: "D:\GoogleDrive\MapSecAssist\CongData.accdb"; DestDir: "{app}"; Flags: ignoreversion; Check: File1(ExpandConstant('{app}\CongData.accdb'));
[Code]
function File1(FilePath3: String): Boolean;
begin
If FileExists(FilePath3) then
Result := False
else
Result := True
begin
if FileExists(FilePath3) then
MsgBox('Congregation Data file is already in your directory ' + FilePath3 + '. '#13 #13 +
'Setup would OVERWRITE this DATA FILE.'#13 #13+
'Please "Back it up" and then DELETE it from this Directory then start install again !', mbError, MB_OK);
end;
end;
答案 0 :(得分:2)
在您的位置,我会使用BeforeInstall
代替Check
。
以下示例:
[Files]
Source: "D:\GoogleDrive\MapSecAssist\CongData.accdb"; DestDir: "{app}";
Flags: ignoreversion; BeforeInstall: File1;
[Code]
var CancelWithoutPrompt: boolean;
function InitializeSetup(): Boolean;
begin
CancelWithoutPrompt := false;
result := true;
end;
procedure File1;
begin
if FileExists(ExpandConstant('{app}\CongData.accdb')) then
begin
MsgBox('Congregation Data file is already in your directory ' +
ExpandConstant('{app}') + '. '#13 #13 +
'Setup would OVERWRITE this DATA FILE.'#13 #13+
'Please "Back it up" and then DELETE it from this Directory then
start install again !', mbError, MB_OK);
CancelWithoutPrompt := true;
WizardForm.Close;
end;
end;
procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
if CurPageID=wpInstalling then
Confirm := not CancelWithoutPrompt;
end;