Advertisement
TLama

Untitled

Jun 3rd, 2015
734
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.24 KB | None | 0 0
  1. [Setup]
  2. AppName=My Program
  3. AppVersion=1.5
  4. DefaultDirName={pf}\My Program
  5.  
  6. [Files]
  7. Source: ".\SystemFiles\vcredist_x86.exe"; Flags: dontcopy
  8.  
  9. [Code]
  10. function IsRuntimeInstalled: Boolean;
  11. begin
  12.   Result := False;
  13.   // here will be a statement that will check whether the runtime is installed
  14.   // and return True if so; see e.g. http://stackoverflow.com/q/11137424/960757
  15. end;
  16.  
  17. function PrepareToInstall(var NeedsRestart: Boolean): string;
  18. var
  19.   ExitCode: Integer;
  20. begin
  21.   // if the runtime is not already installed
  22.   if not IsRuntimeInstalled then
  23.   begin
  24.     // extract the redist to the temporary folder
  25.     ExtractTemporaryFile('vcredist_x86.exe');
  26.     // run the redist from the temp folder; if that fails, return from this handler the error text
  27.     if not Exec(ExpandConstant('{tmp}\vcredist_x86.exe'), '', '', SW_SHOW, ewWaitUntilTerminated, ExitCode) then
  28.     begin
  29.       // return the error text
  30.       Result := 'Setup failed to install VC++ runtime. Exit code: ' + IntToStr(ExitCode);
  31.       // exit this function; this makes sense only if there are further prerequisites to install; in this
  32.       // particular example it does nothing because the function exits anyway, so it is pointless here
  33.       Exit;
  34.     end;
  35.   end;
  36. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement