我的更新必须知道用户指定的目录中是否存在两个已知的文件。如果不是,我想让他知道,这条路上没有文件。到目前为止,这是我所有.isl文件中的一个.isl文件。现在我想给他看他用文件输入的完整路径。
到目前为止,这条消息看起来如下:
在选定的位置找不到File1、File2或两者.
我现在想要的是:
%1,%2或两者都找不到.
对于%1和%2,我想传递完整的指定路径,但我看不出如何做到这一点。ExpandConstant没有任何参数,到目前为止,我还没有发现如何将参数传递给自定义消息。
为了澄清问题,下面是代码:
function NextButtonClick(CurPageID: Integer): Boolean;
var
ResultCode: Integer;
ServerData : String;
UseDatabase : String;
Language : String;
ResultCode : Integer;
ExePath : String;
ConfigFilePath : String;
begin
Result := True;
if CurPageID = wpSelectDir then begin
if DirExists(ExpandConstant('{app}')) then begin
MsgBox(ExpandConstant('{app}'),mbInformation,MB_OK);
UpdatePath := ExpandConstant('{app}');
ExePath := UpdatePath+'\File1.exe';
ConfigFilePath := UpdatePath+'\File2.exe.config';
if FileExists(UpdatePath+'\File1.exe') and FileExists(UpdatePath+'\File2.exe.config') then begin
RegPath := UpdatePath;
UpdatePath := RegPath + '\Update-' + ExpandConstant('{#MyAppVersion}');
ConfigPath := RegPath + '\File2.exe.config';
DBPage.Values[0] := ExtractServerAddr(GetServerData(ConfigPath));
DBPage.Values[1] := ExtractServerPort(GetServerData(ConfigPath));
end else begin
MsgBox(ExpandConstant('{cm:DirPageFileNotFound,ExePath,ConfigFilePath}'),mbInformation,MB_OK);
Result := False;
end;
end else begin
MsgBox(ExpandConstant('{cm:DirPageDirectoryNotFound}'),mbInformation,MB_OK);
Result := False;
end;发布于 2015-11-17 16:49:07
在Pascal脚本中,您应该同时使用CustomMessage和FmtMessage
FmtMessage(CustomMessage('DirPageFileNotFound'), [ExePath, ConfigFilePath])它比组装{cm:MessageName,Arguments} “常数”更干净,更容易出错。例如,如果在任何路径中都有逗号或大括号,你的语法就会中断。
{cm:...}常量用于非Code部分,如:
[Run]
Filename: "myapp.exe"; Description: "{cm:RunningApp,myapp.exe}"; 发布于 2015-11-17 13:03:40
好吧,解决办法是尽可能容易的:
ToExpand := '{cm:DirPageFileNotFound,' + ExePath +',' + ConfigFilePath + '}'
MsgBox(ExpandConstant(ToExpand),mbInformation,MB_OK);这两句台词成功了。
PS:我很感谢StackOverflow是我的橡皮鸭。
https://stackoverflow.com/questions/33755121
复制相似问题