0

heey guys, Im trying to make a installer with a dotnet checker (if .net4 isnt installed it has to instal it) But i cant get it working for some reason..

Any1 that could help? Kind new to inno setup

Im getting an error (unknown identifier 'IsDotNetDetected') at line 56

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

(full code(error at line 54))http://pastebin.com/aD8JX325

thanks :D

chris
  • 161
  • 2
  • 10
  • I guess the `IsDotNetDetected` function [`originates here`](http://www.kynosarges.de/DotNetVersion.html). Also you must have a certain function call after the function body in script, so move your `CheckIsDotNetDetected` after `IsDotNetDetected` when you get it properly copied. – TLama Feb 19 '15 at 09:52
  • yeah im trying to get it working. Tried that now im getting an error at CheckIsDotNetDetected (error is BEGIN expected) – chris Feb 19 '15 at 10:01
  • I can't see your script. But programming is not a trial error process. Try [`this`](http://pastebin.com/keKTUB7m) and try to understand why did you get the error you mentioned. – TLama Feb 19 '15 at 10:07
  • yeah i used that code. But than i get a invalid prototype for 'IsDotNetDetected'. If i searche for that i get linked to [http://stackoverflow.com/questions/15498590/invalid-prototype-when-using-a-check-function i dont understand what they are doing there to fix it – chris Feb 19 '15 at 10:12
  • You must use the `CheckIsDotNetDetected` function for your `Check` parameter in the `[Run]` section, not `IsDotNetDetected` because it doesn't match the expected prototype, that's what that answer says. – TLama Feb 19 '15 at 10:17

1 Answers1

0

To check that .NET framework is installed during installation add the following code section to the install script:

; Check if dot net is insalled
[Code]
function FrameworkIsNotInstalled: Boolean;
begin
  Result := not RegKeyExists(HKEY_LOCAL_MACHINE, 'Software\Microsoft\.NETFramework\policy\v4.0');
end;

// Install dot net with feedback
[Code]
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'), '/q /noreboot', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
    begin
      // you can interact with the user that the installation failed
      MsgBox('.NET installation failed with code: ' + IntToStr(ResultCode) + '.',
        mbError, MB_OK);
    end;
  finally
    WizardForm.StatusLabel.Caption := StatusText;
    WizardForm.ProgressGauge.Style := npbstNormal;
  end;
end;

In the files section add the .NET installer file. Note the flags AfterInstall and Check that will call the functions to check if .NET is installed and install if required.

Source: "C:\Example\dotNetFx40_Full_x86_x64.exe"; DestDir: {tmp}; Flags: deleteafterinstall; AfterInstall: InstallFramework; Check: FrameworkIsNotInstalled
TLama
  • 75,147
  • 17
  • 214
  • 392
Andrew Seaford
  • 645
  • 6
  • 13