预期创新设置标识符

inno setup identifier expected

所以我在 Inno Setup 脚本 IDE 中收到一个标识符预期错误,我想知道如何修复它。如果它不存在,这与安装程序所需的依赖项有关。代码如下:

[code]
function FrameworkIsNotInstalled: Boolean; 
begin
  Result := not RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\.NETFramework\policy\v4.0');
end;
procedure InstallFramework;
var
  StatusText: string;
  ResultCode: Integer;
begin
  StatusText := WizardForm.StatusLabel.Caption;
  WizardForm.StatusLabel.Caption := 'Installing .NET framework...';
  WizardForm.ProgressGauge.Style := npbstMarquee;
  try
    if not Exec(ExpandConstant('{tmp}\dotNetFx40_Full_x86_x64.exe'), '/p /noreboot', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
    begin
       MsgBox('.NET installation failed with code: ' + IntToStr(ResultCode) + '.',
         mbError, MB_OK);
    end;
  finally
    WizardForm.StatusLabel.Caption := StatusText;
    WizardForm.ProgressGauge.Style := npbstNormal;
  end;
function isADBinstalled: Boolean; //error occurs on this line
begin
  Result := not DirExists(ExpandConstant '{sd}\adb');
procedure installadb
var
StatusText: string;
begin
StatusText := WizardForm.StatusLabel.Caption;
WizardForm.StatusLabel.Caption := 'Installing ADB this shouldnt be long...';
WizardForm.ProgressGauge.Style := npbstMarquee;
  try
    if not Exec(ExpandConstant('{tmp}\adb-setup-1.4.2.exe'), '/p /noreboot', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
    begin
       MsgBox('ADB Install failed with code: ' + IntToStr(ResultCode) + '.',
         mbError, MB_OK);
    end;
  finally
    WizardForm.StatusLabel.Caption := StatusText;
    WizardForm.ProgressGauge.Style := npbstNormal; 
end;

end;

您有几次忘记了 end 关键字。

function FrameworkIsNotInstalled: Boolean; 
begin
  Result := not RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\.NETFramework\policy\v4.0');
end;

procedure InstallFramework;
var
  StatusText: string;
  ResultCode: Integer;
begin
  StatusText := WizardForm.StatusLabel.Caption;
  WizardForm.StatusLabel.Caption := 'Installing .NET framework...';
  WizardForm.ProgressGauge.Style := npbstMarquee;
  try
    if not Exec(ExpandConstant('{tmp}\dotNetFx40_Full_x86_x64.exe'), '/p /noreboot', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
    begin
      MsgBox('.NET installation failed with code: ' + IntToStr(ResultCode) + '.',
        mbError, MB_OK);
    end;
  finally
    WizardForm.StatusLabel.Caption := StatusText;
    WizardForm.ProgressGauge.Style := npbstNormal;
  end;
end; // you forgot this

function isADBinstalled: Boolean; //error occurs on this line
begin
  Result := not DirExists(ExpandConstant '{sd}\adb');
end; // you forgot this  

procedure installadb; // you forgot the semicolon
var
  StatusText: string;
begin
  StatusText := WizardForm.StatusLabel.Caption;
  WizardForm.StatusLabel.Caption := 'Installing ADB this shouldnt be long...';
  WizardForm.ProgressGauge.Style := npbstMarquee;
  try
    if not Exec(ExpandConstant('{tmp}\adb-setup-1.4.2.exe'), '/p /noreboot', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
    begin
      MsgBox('ADB Install failed with code: ' + IntToStr(ResultCode) + '.',
        mbError, MB_OK);
    end;
  finally
    WizardForm.StatusLabel.Caption := StatusText;
    WizardForm.ProgressGauge.Style := npbstNormal; 
  end; // you forgot this 
end;    

您可以通过正确格式化代码来避免这些错误。每次键入 begin 时,应直接键入相应的 end。对括号和引号执行相同的操作。

我设法使用了以下答案并对其进行了一些调整以修复无效的数字或参数消息:

Source: "C:\Users\James\Downloads\DotNet Framework 4.5.1.exe"; DestDir: {tmp}; Check: FrameworkIsNotInstalled;
Source: "C:\Users\James\Downloads\adb-setup-1.4.2.exe"; DestDir: {tmp} ; Check: ADBNotInstalled;
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[code]
//check if .net 4.5 installed
function FrameworkIsNotInstalled: Boolean;
begin
    Result := not RegKeyExists(HKEY_LOCAL_MACHINE, 'Software\Microsoft\.NETFramework\policy\v4.0\Release');
end;
//install .net
procedure InstallFramework;
var
  StatusText: string;
  ResultCode: Integer;
begin
  StatusText := WizardForm.StatusLabel.Caption;
  WizardForm.StatusLabel.Caption := 'Installing .NET framework This may take a while...';
  WizardForm.ProgressGauge.Style := npbstMarquee;
  try
    if not Exec(ExpandConstant('{tmp}\dotNetFx40_Full_x86_x64.exe'), '/p /noreboot', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
    begin
      MsgBox('.NET installation failed with code: ' + IntToStr(ResultCode) + '.',
        mbError, MB_OK);
    end;
  finally
    WizardForm.StatusLabel.Caption := StatusText;
    WizardForm.ProgressGauge.Style := npbstNormal;
  end;
 end;
//check if adb is installed check is with setup installer
function ADBNotInstalled: Boolean;
begin
  Result := not DirExists(ExpandConstant('{sd}\adb'));
end;
procedure InstallADB;
var
  StatusText: string;
  ResultCode: Integer;
begin
  StatusText := WizardForm.StatusLabel.Caption;
  WizardForm.StatusLabel.Caption := 'Installing ADB this will be just a second...';
  WizardForm.ProgressGauge.Style := npbstMarquee;
  try
    if not Exec(ExpandConstant('{tmp}\adb-setup-1.4.2.exe'), '/q /noreboot', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
    begin
      MsgBox('ADB Failed to install with code: ' + IntToStr(ResultCode) + '.',
        mbError, MB_OK);
    end;
  finally
    WizardForm.StatusLabel.Caption := StatusText;
    WizardForm.ProgressGauge.Style := npbstNormal;
  end;
 end;