Inno Setup搜索现有文件 [英] Inno setup search for existing file

查看:169
本文介绍了Inno Setup搜索现有文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何搜索现有的exe文件,然后将该目录用于安装程序?

How can I search for an existing exe file and then use that directory for my installer ?

如果找不到exe文件,我希望用户浏览该路径.如果exe文件安装在其他位置.

If the exe file is not found I would like the user to browse for the path. In case the exe file is installed somewhere else.

Senario 1(最常见的情况):

Senario 1 (most common cases):

默认目录为c:\ test \ My program

Default dir is c:\test\My program

这应显示为选择目标位置"页面上的路径 当用户按下一步时,应该进行检查.确保存在默认目录(c:\ test \ My程序) 如果存在,则用户应继续进入准备安装"页面.

This should be shown as the path on the "Select Destination Location" page When the user press Next, there should be a check. To make sure that the default dir exist (c:\test\My program) If it exist, the user should just continue to the Ready to Install page.

Senario 2(很少见):

Senario 2 (very seldom cases):

默认目录为c:\ test \ My program

Default dir is c:\test\My program

这应显示为选择目标位置"页面上的路径 当用户按下一步时,应该进行检查.确保存在默认目录(c:\ test \ My程序) 如果不存在,则应提示用户输入我的程序"的路径.之后,用户应继续进入准备安装"页面. 然后,我只相信用户选择了正确的路径

This should be shown as the path on the "Select Destination Location" page When the user press Next, there should be a check. To make sure that the default dir exist (c:\test\My program) If it does not exist, the user should be prompt for the path to "My program". The user should afterwards continue to the Ready to Install page. I then just trust that the user selects the correct path

如何在InnoSetup中执行此操作?

How can I do this in InnoSetup ?

推荐答案

当找不到预期位置时,我将创建一个文件输入页面,并让用户手动选择Picture.exe二进制位置.

I would make a file input page and let user choose the Picture.exe binary location manually, when it won't be found on expected location.

您可以遵循此代码的 注释版本 :

You can follow the commented version of this code:

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
OutputDir=userdocs:Inno Setup Examples Output

[Files]
Source: "CurrentBinary.exe"; DestDir: "{app}"
Source: "PictureExtension.dll"; DestDir: "{code:GetDirPath}"

[Code]
var
  FilePage: TInputFileWizardPage;

function GetDirPath(const Value: string): string;
begin
  Result := '';
  if FileExists(FilePage.Values[0]) then
    Result := ExtractFilePath(FilePage.Values[0]);
end;         

procedure InitializeWizard;
var
  FilePath: string;
begin
  FilePage := CreateInputFilePage(wpSelectDir, 'Select Picture.exe location', 
    'Where is Picture.exe installed ?', 'Select where Picture.exe is located, ' +
    'then click Next.');
  FilePage.Add('Location of Picture.exe:', 'Picture project executable|Picture.exe', 
    '.exe');

  FilePage.Edits[0].ReadOnly := True;
  FilePage.Edits[0].Color := clBtnFace;

  FilePath := ExpandConstant('{pf}\Picture\Picture.exe');
  if FileExists(FilePath) then
    FilePage.Values[0] := FilePath;
end;

这篇关于Inno Setup搜索现有文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆