我有一个问题编译我的代码,在代码部分出现了错误: “如果不是isdotnetinstalled(),则” eror:参数的数量无效
我觉得我只是抛光一些很小的东西。
[Code]
var
ResultCode: Integer;
procedure InitializeSetup();
begin
// Check if .NET 9.0 is installed before installation starts
if not IsDotNetInstalled() then
begin
MsgBox('The required .NET 9.0 runtime is missing. Installing it now...', mbInformation, MB_OK);
// Run the .NET installer from the temporary directory
if not Exec(ExpandConstant('{tmp}\dotnet-runtime-9.0.2-win-x64.exe'), '', '', SW_SHOWNORMAL, ewWait, ResultCode) then
begin
MsgBox('Failed to install .NET runtime. Error code: ' + IntToStr(ResultCode), mbError, MB_OK);
Abort; // Abort installation if .NET 9.0 is not installed
end;
end;
end;
function IsDotNetInstalled(): Boolean;
var
version: String;
begin
Result := False;
// Check for the presence of .NET 9.0 in the registry
if RegQueryStringValue(HKEY_LOCAL_MACHINE,
'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full',
'Version', version) then
begin
try
// Check if the installed version is greater than or equal to 9.0
if StrToFloat(Copy(version, 1, 3)) >= 9.0 then
Result := True;
except
Result := False;
end;
end;
end;
提前感谢!
IsDotNetInstalled
。通常,您会得到“未知标识符” isDotnetInstalled'。但是实际上有一个构建功能
IsDotNetInstalled
,它需要两个参数。这就是为什么您要获得“参数数量无效”的原因。
在InitializeSetup
之前将功能定义移动。最好以不同的方式命名它,不要引起内置功能的混乱。
(您会发现您的代码中还有其他问题)