将参数传递给.isl文件中定义的自定义消息 [英] Pass parameters to custom messages defined in .isl files
问题描述
我的更新必须确定用户指定的目录中是否存在两个已知文件.如果不是,我想让他知道,此路径上没有文件.到目前为止,这是我所有.isl文件中的 CustomMessage
.现在,我想向他展示他与文件一起输入的完整路径.
My update has to figure out if two known files exist in the directory the user has specified. If not I want to let him know, that there are no files at this path. Up to now, this was a CustomMessage
in all of my .isl Files.
Now I want to show him the complete path he entered with the files.
到目前为止,该消息看起来像这样:
Up to now the message looks like this:
在选定位置找不到文件1,文件2或两者都没有....
File1, File2 or both could not be found at the selected location....
我现在想要的是这样:
%1,%2或两者均未找到...
%1, %2 or both could not be found...
对于%1
和%2
,我想传递完整的指定路径,但是看不到如何执行此操作. ExpandConstant
没有任何参数,到目前为止,我对如何将参数传递给自定义消息一无所知.
For %1
and %2
I want to pass in the complete specified paths, but I cannot see how to do this. ExpandConstant
does not have any arguments, and up to now I've found nothing about how to pass parameters to a custom message.
为澄清起见,下面是代码:
To clarify things, here's the code:
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;
推荐答案
在Pascal脚本中,您应该使用 FmtMessage
:
In Pascal Script you should use CustomMessage
together with FmtMessage
:
FmtMessage(CustomMessage('DirPageFileNotFound'), [ExePath, ConfigFilePath])
与组装 {cm:MessageName,Arguments}
常量" .例如,您的语法会中断,如果任何路径中有逗号或大括号.
It's cleaner and less error prone than assembling the {cm:MessageName,Arguments}
"constant". Your syntax will for example break, if there's any comma or curly bracket in any of the paths.
{cm:...}
常量旨在用于非 Code
部分,例如:
The {cm:...}
constant is intended for use in non-Code
sections, like:
[Run]
Filename: "myapp.exe"; Description: "{cm:RunningApp,myapp.exe}";
类似的问题:将参数传递给.isl文件中定义的自定义消息
这篇关于将参数传递给.isl文件中定义的自定义消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!