Advertisement
Guest User

Untitled

a guest
Dec 9th, 2017
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [Run]
  2. Filename: "{app}\vc_redist.x64.exe"; StatusMsg: "{#VCmsg}"; Check: IsWin64 and not VCinstalled
  3.  
  4. [Code]
  5. function VCinstalled: Boolean;
  6.  // By Michael Weiner <mailto:spam@cogit.net>
  7.  // Function for Inno Setup Compiler
  8.  // 13 November 2015
  9.  // Returns True if Microsoft Visual C++ Redistributable is installed, otherwise False.
  10.  // The programmer may set the year of redistributable to find; see below.
  11.  var
  12.   names: TArrayOfString;
  13.   i: Integer;
  14.   dName, key, year: String;
  15.  begin
  16.   // Year of redistributable to find; leave null to find installation for any year.
  17.   year := '2015';
  18.   Result := False;
  19.   key := 'Software\Microsoft\Windows\CurrentVersion\Uninstall';
  20.   // Get an array of all of the uninstall subkey names.
  21.   if RegGetSubkeyNames(HKEY_LOCAL_MACHINE, key, names) then
  22.    // Uninstall subkey names were found.
  23.    begin
  24.     i := 0
  25.     while ((i < GetArrayLength(names)) and (Result = False)) do
  26.      // The loop will end as soon as one instance of a Visual C++ redistributable is found.
  27.      begin
  28.       // For each uninstall subkey, look for a DisplayName value.
  29.       // If not found, then the subkey name will be used instead.
  30.       if not RegQueryStringValue(HKEY_LOCAL_MACHINE, key + '\' + names[i], 'DisplayName', dName) then
  31.        dName := names[i];
  32.       // See if the value contains both of the strings below.
  33.       Result := (Pos(Trim('Visual C++ ' + year),dName) * Pos('Redistributable',dName) <> 0)
  34.       i := i + 1;
  35.      end;
  36.    end;
  37.  end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement