我需要我的安装程序检查目标位置中是否存在文件,如果不存在,则安装将中止。我的项目是一个更新补丁,因此我希望安装程序在应用程序的主 exe 不在目标中时避免安装更新文件。我怎样才能做到这一点?
有人可以给出一个通过 Windows 注册表检查文件版本的代码示例吗?
[Files]
Source C:\filename.exe; DestDir {app}; Flags: ignoreversion; BeforeInstall: CheckForFile;
[code]
procedure CheckForFile(): Boolean;
begin
if (FileExists('c:\somefile.exe')) then
begin
MsgBox('File exists, install continues', mbInformation, MB_OK);
Result := True;
end
else
begin
MsgBox('File does not exist, install stops', mbCriticalError, MB_OK);
Result := False;
end;
end;
只是在用户选择正确的文件夹之前不要让他们继续。
function NextButtonClick(PageId: Integer): Boolean;
begin
Result := True;
if (PageId = wpSelectDir) and not FileExists(ExpandConstant('{app}\yourapp.exe')) then begin
MsgBox('YourApp does not seem to be installed in that folder. Please select the correct folder.', mbError, MB_OK);
Result := False;
exit;
end;
end;
当然,尝试自动为它们选择正确的文件夹也是一个好主意,例如。通过从注册表中检索正确的位置。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)