Inno Setup - Pascal 代码可见性 - "Unknown identifier" 错误

Inno Setup - Pascal code visibility - "Unknown identifier" error

我的安装程序中有一个文件,其 AfterInstall 操作如下:

AfterInstall: UpdateImageLoaderConfigValues()

而且我希望程序调用同一个 Pascal Script 函数两次,因为据我所知我不能有两个 AfterInstall 操作,所以我这样设置:

procedure UpdateImageLoaderConfigValues();
begin
  SaveValueToXML(ExpandConstant('{app}\ImageLoader.exe.config'),{#ImageLoaderLastConfigurationPath}, ExpandConstant('{app}/Configurations'))
  SaveValueToXML(ExpandConstant('{app}\ImageLoader.exe.config'),{#ImageLoaderLastImagePath}, ExpandConstant('{app}/Images'))
end;

我的函数 SaveValueToXML 有一个签名:

function SaveValueToXML(const AFileName, APath, AValue: string);

问题是编译失败是因为

Unknown identifier 'SaveValueToXML'

UpdateImageLoaderConfigValues 我尝试使用此功能的地方出现错误。

如何让 SaveValueToXMLUpdateImageLoaderConfigValues 可见?

您必须在 UpdateImageLoaderConfigValues:

之前定义 SaveValueToXML
[Files]
Source: ...; AfterInstall: UpdateImageLoaderConfigValues()

[Code]

function SaveValueToXML(const AFileName, APath, AValue: string);
begin
  { ... }
end;

procedure UpdateImageLoaderConfigValues();
begin
  SaveValueToXML(ExpandConstant('{app}\ImageLoader.exe.config'),{#ImageLoaderLastConfigurationPath}, ExpandConstant('{app}/Configurations'))
  SaveValueToXML(ExpandConstant('{app}\ImageLoader.exe.config'),{#ImageLoaderLastImagePath}, ExpandConstant('{app}/Images'))
end;

对于到达此处并出现相同错误消息的其他人,但在变量标识符上,而不是在 functionprocedure 调用上,请参见 .