Код:
[Setup]
AppName=DeltaMAX
AppVerName=DeltaMAX 2.0.1.0
DefaultDirName={tmp}
OutputDir=.
[Files]
Source: {#ifdef UNICODE}Unicode\{#endif}DeltaMAX.dll; Flags: dontcopy;
Source: InnoCallback.dll; Flags: dontcopy
[Code]
type
TMessageCallback = function(nMessageCode: Integer; lpUserData: LongWord): BOOL;
TProgressCallback = function(dPercentDone: Single; lpUserData: LongWord): BOOL;
TDeltaMAXEncodeOptions = record
lpszLicensedTo: string;
lpszLicenseKey: string;
nMemoryMax: Integer;
nMemoryMaxPercent: Integer;
nFreeMemoryMin: Integer;
nLowMemMode: Integer;
nFootprintSize: Integer;
bAutoIncreaseFootprintSize: BOOL;
bEnableMultiPass: BOOL;
nMultiPassThreshold: Integer;
nMultiPassMaxAdditionalPasses: Integer;
pProgressCallback: LongWord;
pMessageCallback: LongWord;
lpUserData: LongWord;
end;
function WrapMessageCallback(Callback: TMessageCallback; ParamCount: Integer): LongWord; external 'wrapcallback@files:innocallback.dll stdcall';
function WrapProgressCallback(Callback: TProgressCallback; ParamCount: Integer): LongWord; external 'wrapcallback@files:innocallback.dll stdcall';
procedure DeltaMAXInitEncodeOptions(var pOptions: TDeltaMAXEncodeOptions); external 'DeltaMAXInitEncodeOptions@files:DeltaMAX.dll cdecl';
function DeltaMAXEncode(szSource, szTarget, szDiff: string; var pOptions: TDeltaMAXEncodeOptions): Integer; external 'DeltaMAXEncode@files:DeltaMAX.dll cdecl';
function ProgressCallback(dPercentDone: Single; lpUserData: LongWord): BOOL;
begin
Result := True;
Log(Format('Progress: %n%%', [dPercentDone]));
end;
function MessageCallback(nMessageCode: Integer; lpUserData: LongWord): BOOL;
begin
Result := True;
Log(Format('Message code: %d', [nMessageCode]));
end;
function InitializeSetup: Boolean;
var
LOptions: TDeltaMAXEncodeOptions;
LResultCode: Integer;
begin
try
DeltaMAXInitEncodeOptions(LOptions);
LOptions.lpszLicensedTo := 'DEMO';
LOptions.lpszLicenseKey := 'DEMO';
LOptions.bEnableMultiPass := False;
LOptions.nMultiPassThreshold := 0;
LOptions.nMultiPassMaxAdditionalPasses := 1;
LOptions.pProgressCallback := WrapProgressCallback(@ProgressCallback, 2);
LOptions.pMessageCallback := WrapMessageCallback(@MessageCallback, 2);
LResultCode := DeltaMAXEncode(ExpandConstant('{src}\1.txt'), ExpandConstant('{src}\2.txt'), ExpandConstant('{src}\patch.diff'), LOptions);
if LResultCode <> 0 then
RaiseException(Format('Encode failed with error code: %d', [LResultCode]));
except
ShowExceptionMessage;
finally
end;