Inno setup 使用检查函数时原型无效

Inno setup 使用检查函数时原型无效,inno-setup,Inno Setup,我是InnoSetup的新手,因为我正在尝试各种安装程序 我使用Inno script Studio和内置向导创建了我的第一个脚本。到现在为止,一直都还不错。现在,我想让它检测是否安装了.NET4.5,如果没有,则安装它。所以,我浏览了整个网页,在这里我发现了,但是当我复制并粘贴代码到我的脚本中时,我在编译时遇到了以下错误 Compiling [Code] section Compiler Error! Line 54: Column 10: Invalid prototype for 'IsD

我是InnoSetup的新手,因为我正在尝试各种安装程序

我使用Inno script Studio和内置向导创建了我的第一个脚本。到现在为止,一直都还不错。现在,我想让它检测是否安装了.NET4.5,如果没有,则安装它。所以,我浏览了整个网页,在这里我发现了,但是当我复制并粘贴代码到我的脚本中时,我在编译时遇到了以下错误

Compiling [Code] section
Compiler Error!
Line 54: Column 10: Invalid prototype for 'IsDotNetDetected'
我的剧本第54行是这样的

function IsDotNetDetected(version: string; service: cardinal): boolean;
有人知道这个错误是什么意思以及我为什么会得到它吗

以下是我的完整脚本:

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "AVO Log"
#define MyAppVersion "0.1.0.1"
#define MyAppPublisher "NA"
#define MyAppExeName "AVO Log.exe"

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{9476587F-A670-4E17-B8EA-A6FABB345968}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}  
AppPublisher={#MyAppPublisher}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1

[Files]
Source: "G:\Common\Gareths Apps\dotNetFx45_Full_x86_x64.exe"; DestDir: {tmp}; Flags: deleteafterinstall;
Source: "C:\Visual Studio 2010\Projects\AVO Log\AVO Log\bin\Release\AVO Log.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Visual Studio 2010\Projects\AVO Log\AVO Log\bin\Release\GalaSoft.MvvmLight.Extras.WPF45.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Visual Studio 2010\Projects\AVO Log\AVO Log\bin\Release\GalaSoft.MvvmLight.WPF45.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Visual Studio 2010\Projects\AVO Log\AVO Log\bin\Release\GalaSoft.MvvmLight.WPF45.xml"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Visual Studio 2010\Projects\AVO Log\AVO Log\bin\Release\Microsoft.Expression.Interactions.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Visual Studio 2010\Projects\AVO Log\AVO Log\bin\Release\Microsoft.Practices.ServiceLocation.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Visual Studio 2010\Projects\AVO Log\AVO Log\bin\Release\System.Windows.Interactivity.dll"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon

[Run]
Filename: "{tmp}\dotNetFx45_Full_x86_x64.exe"; Check: IsDotNetDetected('v4.5',0)
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

[Code]
function IsDotNetDetected(version: string; service: cardinal): boolean;
// Indicates whether the specified version and service pack of the .NET Framework is installed.
//
// version -- Specify one of these strings for the required .NET Framework version:
//    'v1.1.4322'     .NET Framework 1.1
//    'v2.0.50727'    .NET Framework 2.0
//    'v3.0'          .NET Framework 3.0
//    'v3.5'          .NET Framework 3.5
//    'v4\Client'     .NET Framework 4.0 Client Profile
//    'v4\Full'       .NET Framework 4.0 Full Installation
//    'v4.5'          .NET Framework 4.5
//
// service -- Specify any non-negative integer for the required service pack level:
//    0               No service packs required
//    1, 2, etc.      Service pack 1, 2, etc. required
var
key: string;
install, release, serviceCount: cardinal;
check45, success: boolean;
begin
// .NET 4.5 installs as update to .NET 4.0 Full
if version = 'v4.5' then begin
    version := 'v4\Full';
    check45 := true;
end else
    check45 := false;

// installation key group for all .NET versions
key := 'SOFTWARE\Microsoft\NET Framework Setup\NDP\' + version;

// .NET 3.0 uses value InstallSuccess in subkey Setup
if Pos('v3.0', version) = 1 then begin
    success := RegQueryDWordValue(HKLM, key + '\Setup', 'InstallSuccess', install);
end else begin
    success := RegQueryDWordValue(HKLM, key, 'Install', install);
end;

// .NET 4.0/4.5 uses value Servicing instead of SP
if Pos('v4', version) = 1 then begin
    success := success and RegQueryDWordValue(HKLM, key, 'Servicing', serviceCount);
end else begin
    success := success and RegQueryDWordValue(HKLM, key, 'SP', serviceCount);
end;

// .NET 4.5 uses additional value Release
if check45 then begin
    success := success and RegQueryDWordValue(HKLM, key, 'Release', release);
    success := success and (release >= 378389);
end;

result := success and (install = 1) and (serviceCount >= service);
end;

32位系统的.Net 4检查示例

function NET4032(): Boolean;
var
InstallCheck : Cardinal;
begin
  RegQueryDWordValue(HKLM32, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full', 
'Install', InstallCheck);
    if InstallCheck = $1 then
       Result := false
    else
       Result := true;
end;

我的灵能告诉我,你试图将此函数用作
检查:
参数。由于与
check:
参数一起使用的函数必须具有,编译器将失败

尝试使用此存根函数:

function CheckIsDotNetDetected(): boolean;
begin
    result := IsDotNetDetected('v4\Client', 0);
end;

@Gaz83您没有明确提到您正在使用
检查:
参数。这是你在原文章上添加的一个问题,导致了这个问题。@Deanna抱歉,如果这听起来很愚蠢,那你是什么意思?在原始文章中,作者在
InitializeSetup()
函数中使用了
检查:
。虽然我没有使用该功能,但我仍在运行
检查:
。请参阅
[Run]
下的第一行。。。除非我完全做错了,否则那篇文章的作者将该函数用作签入代码,而不是节条目的参数。好吧,那么我需要对我的脚本做什么才能让它工作呢?我基本上想检查是否安装了.Net 4.5,如果没有安装,然后用我包含的dotNetFx45_Full_x86_x64.exe安装。我想我可能已经找到了答案,只是做了一些工作testing@TLama-你可以纠正我的回答:D.当谈论技能和知识时,我离你有一百万英里远。。。