[英]"Identifier Expected" or "Invalid Prototype" when implementing a scripted constant in Inno Setup
[英]Inno Setup: Invalid Prototype
我收到“'CheckForFile' 的原型无效”。 经过数小时尝试设置下载和安装文件(下载部分有效,但我找不到运行下载文件的方法),我没有想法。 为什么我会收到这个错误?
[Run]
Filename: "{tmp}\AcroRdrDC1800920044_en_US.exe"; Description: "Install Adobe Reader"; Flags: shellexec skipifsilent; BeforeInstall: CheckForFile('{tmp}\AcroRdrDC1800920044_en_US.exe');
[Code]
function CheckForFile(Param: String): Boolean;
begin
Result := FileExists(Param)
end;
虽然评论中已经存在一些事实,但无论如何我还是想分享我到目前为止所学到的知识,以防万一有人需要。
我的观察是
Check
参数与返回boolean
的function
一起使用,则不会出现Invalid Prototype错误BeforeInstall
或AfterInstall
参数与procedure
一起使用,则也没有错误这使我得出以下结论:
在[Files]
条目的参数中使用过程或函数时, Inno Setup会为此函数或过程创建原型。
BeforeInstall
和AfterInstall
的procedure
原型,因为它们不期望返回值Check
的function : boolean
原型,因为这个函数需要一个返回值处理完[Files]
部分后,将处理[Code]
部分。 因为CheckForFile
的原型已经被声明为procedure CheckFile(...);
声明function CheckFile(...) : boolean
与原型不匹配并显示错误。
因此,将功能更改为过程将在技术上起作用,但在您的情况下使用Check
将是可行的方法。 如果我们想在安装之前执行某些操作,可以使用BeforeInstall
,但它不允许返回值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.