代码之家  ›  专栏  ›  技术社区  ›  Wernfried Domscheit

在Inno设置中提示用户快捷方式中要使用的文件

  •  2
  • Wernfried Domscheit  · 技术社区  · 7 年前

    "C:\Program Files (x86)\MapInfo\Professional\MapInfow.exe" "{app}\DPImap.MBX"
    

    MapInfow.exe

    ; Default value for silent installion
    #define MapInfoDefault AddBackslash(GetEnv("ProgramFiles(x86)")) + "MapInfo\Professional\MapInfow.exe"
    
    [Tasks]
    Name: desktopicon; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm:AdditionalIcons}; Flags: unchecked
    
    [Icons]
    Name: {group}\DPImap; Filename: {code:MapInfoExecutable} {app}\DPImap.mbx
    Name: {userdesktop}\DPImap; Filename: {code:MapInfoExecutable} {app}\DPImap.mbx; Tasks: desktopicon
    
    [Code]    
    
    function MapInfoExecutable(Param: String): String;
    var
        FileName: string;
    begin
        FileName := '';
        if GetOpenFileName('Locate your MapInfo Application', FileName, ExpandConstant('{pf32}'), 'Executable (*.exe)|*.exe', 'exe') then
            Result := FileName
        else
            { Return default #MapInfoDefault if user does not provide any file }
            Result := ExpandConstant('{#MapInfoDefault}');
    end;
    

    如何提供正确的用户对话框?

    1 回复  |  直到 7 年前
        1
  •  2
  •   Martin Prikryl    7 年前

    应该是:

    [Icons]
    Name: {group}\DPImap; Filename: "{code:MapInfoExecutable}"; \
        Parameters: """{app}\DPImap.mbx"""
    

    var
      FileName: string;
    
    function MapInfoExecutable(Param: String): String;
    begin
      if FileName = '' then
      begin
        if not GetOpenFileName(
            'Locate your MapInfo Application', FileName, ExpandConstant('{pf32}'),
            'Executable (*.exe)|*.exe', 'exe') then
        begin
          { Return default #MapInfoDefault if user does not provide any file }
          FileName := '{#MapInfoDefault}';
        end;
      end;
      Result := FileName;
    end;
    

    Inno Setup Prompt for external file location

    MapInfoExecutable


    注意我已经移除了 ExpandConstant '{#MapInfoDefault}' -这是胡说八道。参见 Evaluate preprocessor macro on run time in Inno Setup Pascal Script