Advertisement
TLama

Untitled

Jan 3rd, 2014
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.57 KB | None | 0 0
  1. [Files]
  2. Source: "7za.exe"; Flags: dontcopy
  3.  
  4. [Code]
  5. const
  6.   ERROR_7_ZIP_NO_ERROR = 0;
  7.   ERROR_7_ZIP_WARNING = 1;
  8.   ERROR_7_ZIP_FATAL_ERROR = 2;
  9.   ERROR_7_ZIP_CMD_LINE_ERROR = 7;
  10.   ERROR_7_ZIP_NOT_ENOUGH_MEMORY = 8;
  11.   ERROR_7_ZIP_USER_ABORT = 255;
  12.  
  13. procedure CurStepChanged(CurStep: TSetupStep);
  14. var
  15.   ResultCode: Integer;
  16. begin
  17.   if CurStep = ssPostInstall then
  18.   begin
  19.     if idpFilesDownloaded then
  20.     begin
  21.       // extract the archiver tool into the temporary folder
  22.       ExtractTemporaryFile('7za.exe');
  23.       // and execute it
  24.       if Exec(ExpandConstant('{tmp}\7za.exe'), ExpandConstant('x {app}\File.zip -o{app}\Extracted\'),
  25.         '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then
  26.       begin
  27.         // the execution of the tool succeeded, but it doesn't mean that
  28.         // extraction was successful; now we need to determine what exit
  29.         // code the tool returned (for more information follow this link
  30.         // http://sevenzip.sourceforge.jp/chm/cmdline/exit_codes.htm)
  31.         case ResultCode of
  32.           ERROR_7_ZIP_NO_ERROR: ; // all the files were successfully extracted
  33.           ERROR_7_ZIP_WARNING: ; // you can react somehow on the rest of the errors somehow
  34.           ERROR_7_ZIP_FATAL_ERROR: ;
  35.           ERROR_7_ZIP_CMD_LINE_ERROR: ;
  36.           ERROR_7_ZIP_NOT_ENOUGH_MEMORY: ;
  37.           ERROR_7_ZIP_USER_ABORT: ;
  38.         end;
  39.       end
  40.       else
  41.       begin
  42.         // the execution of the archiver tool failed; from SysErrorMessage(ResultCode)
  43.         // you can get the reason of the failure
  44.       end;
  45.     end;
  46.   end;
  47. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement