Reputation: 19207
I have revised my function like this:
function IsVCRedist32BitNeeded(): boolean;
var
Major, Minor, Bld, Rbld: Cardinal;
VCRuntimeInstalled: boolean;
begin
VCRuntimeInstalled := false; { Assume that VC Runtime is not installed }
Result := true;
{ Version number is: Major.Minor.Bld.Rbld }
{ Minimum valid version is: 14.14.26429.03 }
if (RegQueryDWordValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x86', 'Major', Major) and
RegQueryDWordValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x86', 'Minor', Minor) and
RegQueryDWordValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x86', 'Bld', Bld) and
RegQueryDWordValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x86', 'Rbld', Rbld)) then
begin
VCRuntimeInstalled := true;
end
else if (RegQueryDWordValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x86', 'Major', Major) and
RegQueryDWordValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x86', 'Minor', Minor) and
RegQueryDWordValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x86', 'Bld', Bld) and
RegQueryDWordValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x86', 'Rbld', Rbld)) then
begin
VCRuntimeInstalled := true;
end;
if(VCRuntimeInstalled) then
begin
{ Is the installed version at least 14.14 ? }
Result := Major < 14 or
(Major = 14 and (Minor < 14 or
(Minor = 14 and (Bld < 26429 or
(Bld = 26429 and Rbld < 3)))));
{ 'true' means we need to run the installer }
if (Result) then
begin
Log('Visual Studio Redist x86 is not already installed');
Result := True;
end
else
Log(FmtMessage('Visual Studio Redist x86 Version : found v%1.%2.%3.%4', [Major, Minor, Bld, Rbld]));
end;
end;
end;
It will not compile. It complains about line 978 having a type mismatch:
Result := Major < 14 or
(Major = 14 and (Minor < 14 or
(Minor = 14 and (Bld < 26429 or
(Bld = 26429 and Rbld < 3)))));
What is wrong?
Upvotes: 1
Views: 245
Reputation: 202692
Pascal Script seems to have a non-standard operator precedence.
Additional brackets will solve this (and it's always better to use them anyway):
Result := (Major < 14) or
((Major = 14) and ((Minor < 14) or
((Minor = 14) and ((Bld < 26429) or
((Bld = 26429) and (Rbld < 3))))));
Upvotes: 2
Reputation: 5472
There is no need to do any check about VC++ runtime.
Simply install them - nothing bad happens if it is already installed. Also the installation takes only few moments so you can continue in doing whatever do in installer (you do not need to wait it to finish).
Also the VC++ runtime required on target machine depends on you application and how you setup it up during development in Visual Studio.
Upvotes: 0