daily pastebin goal
18%
SHARE
TWEET

Untitled

a guest Dec 9th, 2017 151 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define VCmsg "Installing Microsoft Visual C++ Redistributable...."
  2.  
  3. [Run]
  4. ; 2015
  5. Filename: "{app}\vc_redist.x64.exe"; StatusMsg: "{#VCmsg}"; Check: IsWin64 and not VCinstalled2015
  6. Filename: "{app}\vc_redist.x86.exe"; StatusMsg: "{#VCmsg}"; Check: not IsWin64 and not VCinstalled2015
  7. ; other versions
  8.  
  9.  
  10. [Code]
  11. function VCinstalled: Boolean;
  12. // Works for every version of Visual C++ Redistributable except 2015
  13.  var
  14.   names: TArrayOfString;
  15.   i: Integer;
  16.   dName, key, year: String;
  17.  begin
  18.   // Year of redistributable to find; leave null to find installation for any year.
  19.   year := '2017';
  20.   Result := False;
  21.   key := 'Software\Microsoft\Windows\CurrentVersion\Uninstall';
  22.   // Get an array of all of the uninstall subkey names.
  23.   if RegGetSubkeyNames(HKEY_LOCAL_MACHINE, key, names) then
  24.    // Uninstall subkey names were found.
  25.    begin
  26.     i := 0
  27.     while ((i < GetArrayLength(names)) and (Result = False)) do
  28.      // The loop will end as soon as one instance of a Visual C++ redistributable is found.
  29.      begin
  30.       // For each uninstall subkey, look for a DisplayName value.
  31.       // If not found, then the subkey name will be used instead.
  32.       if not RegQueryStringValue(HKEY_LOCAL_MACHINE, key + '\' + names[i], 'DisplayName', dName) then
  33.        dName := names[i];
  34.       // See if the value contains both of the strings below.
  35.       Result := (Pos(Trim('Visual C++ ' + year),dName) * Pos('Redistributable',dName) <> 0)
  36.       i := i + 1;
  37.      end;
  38.    end;
  39.  end;
  40.  
  41.  [Code]
  42. function VCinstalled2015: Boolean;
  43. // Works only for Visual C++ Redistributable 2015, because the label is
  44. // Microsoft Visual C++ 2015 x64 Minimum Runtime - 14.0.23026
  45.  var
  46.   names: TArrayOfString;
  47.   i: Integer;
  48.   dName, key, year: String;
  49.  begin
  50.   // Year of redistributable to find; leave null to find installation for any year.
  51.   year := '2015';
  52.   Result := False;
  53.   key := 'Software\Microsoft\Windows\CurrentVersion\Uninstall';
  54.   // Get an array of all of the uninstall subkey names.
  55.   if RegGetSubkeyNames(HKEY_LOCAL_MACHINE, key, names) then
  56.    // Uninstall subkey names were found.
  57.    begin
  58.     i := 0
  59.     while ((i < GetArrayLength(names)) and (Result = False)) do
  60.      // The loop will end as soon as one instance of a Visual C++ redistributable is found.
  61.      begin
  62.       // For each uninstall subkey, look for a DisplayName value.
  63.       // If not found, then the subkey name will be used instead.
  64.       if not RegQueryStringValue(HKEY_LOCAL_MACHINE, key + '\' + names[i], 'DisplayName', dName) then
  65.        dName := names[i];
  66.       // See if the value contains both of the strings below.
  67.       Result := (Pos(Trim('Visual C++ ' + year),dName) <> 0)
  68.       i := i + 1;
  69.      end;
  70.    end;
  71.  end;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top