delphi - Inno setup command line progress -
how can progress when i'm executing inno script command line compiler (iscc.exe)?
i can pipeline output want % completed well.
use iscmplr
library instead. inspiration, basic delphi innosetup compiler might (of course without hardcoded paths). uses original compint.pas
unit innosetup source pack:
unit unit1; interface uses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, stdctrls, comctrls, compint; const complib = iscmplrdll; comppath = 'c:\program files (x86)\inno setup 5\'; compscriptproc = {$ifndef unicode}'isdllcompilescript'{$else}'isdllcompilescriptw'{$endif}; type tcompscriptproc = function(const params: tcompilescriptparamsex): integer; stdcall; pappdata = ^tappdata; tappdata = record lines: tstringlist; linenumber: integer; statuslabel: tlabel; progressbar: tprogressbar; end; type tform1 = class(tform) label1: tlabel; button1: tbutton; progressbar1: tprogressbar; procedure formcreate(sender: tobject); procedure formdestroy(sender: tobject); procedure button1click(sender: tobject); private fcomplibhandle: hmodule; fcompscriptproc: tcompscriptproc; public { public declarations } end; var form1: tform1; implementation {$r *.dfm} procedure tform1.formcreate(sender: tobject); begin fcomplibhandle := safeloadlibrary(comppath + complib); if fcomplibhandle <> 0 fcompscriptproc := getprocaddress(fcomplibhandle, compscriptproc); end; procedure tform1.formdestroy(sender: tobject); begin if fcomplibhandle <> 0 freelibrary(fcomplibhandle); end; function compilercallbackproc(code: integer; var data: tcompilercallbackdata; appdata: longint): integer; stdcall; begin // in every stage can cancel compilation if pass e.g. boolean // field through appdata using following line: // result := iscrrequestabort; result := iscrsuccess; case code of iscbreadscript: pappdata(appdata)^ begin if data.reset linenumber := 0; if linenumber < lines.count begin data.lineread := pchar(lines[linenumber]); inc(linenumber); end; end; iscbnotifystatus: form1.label1.caption := data.statusmsg; iscbnotifyidle: begin pappdata(appdata)^ begin progressbar.max := data.compressprogressmax; progressbar.position := data.compressprogress; statuslabel.caption := format('bitrate: %d b/s; remaining time: %d s', [data.bytescompressedpersecond, data.secondsremaining]); application.processmessages; end; end; iscbnotifysuccess: showmessagefmt('yipee! compilation succeeded; output: %s', [data.outputexefilename]); iscbnotifyerror: showmessagefmt('an error occured! file: %s; line: %d; message: %s', [data.errorfilename, data.errorline, data.errormsg]); end; end; procedure tform1.button1click(sender: tobject); var custdata: tappdata; compparams: tcompilescriptparamsex; begin if assigned(fcompscriptproc) begin custdata.lines := tstringlist.create; try custdata.lines.loadfromfile('c:\program files (x86)\inno setup 5\examples\example1.iss'); custdata.linenumber := 0; custdata.statuslabel := label1; custdata.progressbar := progressbar1; compparams.size := sizeof(compparams); compparams.compilerpath := comppath; // path folder containing *.e32 files (innosetup install folder) compparams.sourcepath := 'c:\program files (x86)\inno setup 5\examples\'; // path script file compiled compparams.callbackproc := compilercallbackproc; // callback procedure compiler calls read script , status notifications pointer(compparams.appdata) := @custdata; // custom data passed callback procedure compparams.options := ''; // additional options; see compint.pas description if fcompscriptproc(compparams) <> iscenoerror showmessage('compiler error'); custdata.lines.free; end; end; end; end.
Comments
Post a Comment