This works fine but ALWAYS install the VC_redist.x86.exe
Is there a way improve the Inno script so it checks if the system already has the necessary runtime and only install it when needed?
No, it doesn’t. And i do not know why. But the following made my installers work smooth again:
[code][Run]
Filename: “vc_redist.x86.exe”; StatusMsg: “Installing Microsoft Visual C++ Redistributable on x86 …”; Check: not IsWin64 and not VCinstalled
Filename: “vc_redist.x64.exe”; StatusMsg: “Installing Microsoft Visual C++ Redistributable on x64…”; Check: IsWin64 and not VCinstalled
(Code) // This has been changed for the Forum Display. Use [ and ] in InnoSetup please.
function VCinstalled: Boolean;
// Returns True if Microsoft Visual C++ Redistributable is installed, otherwise False.
// The programmer may set the year of redistributable to find; see below.
var
names: TArrayOfString;
i: Integer;
dName, key, year: String;
begin
// Year of redistributable to find; leave null to find installation for any year.
year := ‘’;
Result := False;
key := ‘Software\Microsoft\Windows\CurrentVersion\Uninstall’;
// Get an array of all of the uninstall subkey names.
if RegGetSubkeyNames(HKEY_LOCAL_MACHINE, key, names) then
// Uninstall subkey names were found.
begin
i := 0
while ((i < GetArrayLength(names)) and (Result = False)) do
// The loop will end as soon as one instance of a Visual C++ redistributable is found.
begin
// For each uninstall subkey, look for a DisplayName value.
// If not found, then the subkey name will be used instead.
if not RegQueryStringValue(HKEY_LOCAL_MACHINE, key + ‘\’ + names[i], ‘DisplayName’, dName) then
dName := names[i];
// See if the value contains both of the strings below.
Result := (Pos(Trim('Visual C++ ’ + year),dName) * Pos(‘Redistributable’,dName) <> 0)
i := i + 1;
end;
end;[/code]
[quote=279845:@Michel Bujardet]My app will be 32 bit, but I want it to install on Windows 64 bit as well as 32 bit Windows.
What is the redistribuable that must be installed ? only x86 ?[/quote]
Yes, it is based on your app build, not the OS type a user might run on. So a 32-bit Windows app would use the 32-bit redist or include the 32-bit DLLs.