Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define VCmsg "Installing Microsoft Visual C++ Redistributable...."
- [Run]
- ; 2015
- Filename: "{app}\vc_redist.x64.exe"; StatusMsg: "{#VCmsg}"; Check: IsWin64 and not VCinstalled2015
- Filename: "{app}\vc_redist.x86.exe"; StatusMsg: "{#VCmsg}"; Check: not IsWin64 and not VCinstalled2015
- ; other versions
- [Code]
- function VCinstalled: Boolean;
- // Works for every version of Visual C++ Redistributable except 2015
- var
- names: TArrayOfString;
- i: Integer;
- dName, key, year: String;
- begin
- // Year of redistributable to find; leave null to find installation for any year.
- year := '2017';
- 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;
- end;
- [Code]
- function VCinstalled2015: Boolean;
- // Works only for Visual C++ Redistributable 2015, because the label is
- // Microsoft Visual C++ 2015 x64 Minimum Runtime - 14.0.23026
- var
- names: TArrayOfString;
- i: Integer;
- dName, key, year: String;
- begin
- // Year of redistributable to find; leave null to find installation for any year.
- year := '2015';
- 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) <> 0)
- i := i + 1;
- end;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement