开发者

How can I check that .NET Framework 4.0 is installed on a computer via an Inno script used to deploy software on that computer?

开发者 https://www.devze.com 2023-03-22 15:09 出处:网络
I\'ve read the previous post on this topic: Inno Setup: Verify that .NET 4.0 is installed and have tried using the suggested code in my script. I\'ve made some modifications for testing purposes, bu

I've read the previous post on this topic:

Inno Setup: Verify that .NET 4.0 is installed

and have tried using the suggested code in my script. I've made some modifications for testing purposes, but nothing that I believe is substantial:

[Code]
function IsDotNetDetected(version: string; service: cardinal): boolean;
// Indicates whether .NET Framework 4.0 is installed
// Taken from www.kynosarges.de/DotNetVersion.html
var
  key: string;
  install, serviceCount: cardinal;
  success: boolean;
begin
  key := 'SOFTWARE\Microsoft\NET Framework Setup\NDP\' + version;
  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;
  result := success and (install = 1) and (serviceCount >= service);
end;

function InitalizeSetup(): Boolean;
begin
  if not IsDotNetDetected('v4\Full', 0) then begin
    MsgBox('AppName requires Microsoft .NET Framework 4.0 Full Profile.'#13#13
        'Please download this from www.zemax.com/updates,'#13
        'and the开发者_C百科n re-run the AppName setup program.', mbInformation, MB_OK);
    result := false;
  end else begin
    MsgBox('Found Microsoft .NET Framework 4.0.', mbInformation, MB_OK);
    result := true;
  end;
end;

However, this doesn't seem to work, and I cannot figure out why. When I compile the script, almost always the compilation hangs on the section of my script containing the code (above). If the script compilation is completed, and I begin to deploy the software, I never see a message box indicating either the presence or lack thereof of .NET Framework 4.0. Any help would be greatly appreciated. Thank you!


you have a Typo, the function name must be InitializeSetup instead of InitalizeSetup.

0

精彩评论

暂无评论...
验证码 换一张
取 消