Delphi DLL AbortCheck Callbacks
The Chilkat Delphi DLL (non-ActiveX) supports callbacks starting in version 9.5.0.82, to be released in Feb 2020. Pre-release Beta builds are available upon request.
Also see:
- Delphi DLL PercentDone Callbacks
- Delphi DLL ProgressInfo Callbacks
- Delphi DLL TaskCompleted Callbacks
1) First define a function exactly as shown here. Make sure to use the “cdecl” calling convention. Returning a non-zero Result will cause the Chilkat method to abort.
function MyAbortCheck(): Integer; cdecl;
begin
Form1.Memo1.Lines.Add('AbortCheck!');
Result := 0;
end;
2) Set the abort check callback by calling the appropriate SetAbortCheck function. For the CkZip object it is CkZip_SetAbortCheck(zip,MyAbortCheck);
Note: This example shows AbortCheck events using CkZip. The same technique applies to any Chilkat class having callbacks.
For example, CkRest_SetAbortCheck.
procedure TForm1.Button1Click(Sender: TObject);
var
zip: HCkZip;
success: Boolean;
recurse: Boolean;
begin
zip := CkZip_Create();
success := CkZip_NewZip(zip,'C:/temp/out.zip');
if (success == False) then
begin
Memo1.Lines.Add(CkZip__lastErrorText(zip));
Exit;
end;
recurse := True;
success := CkZip_AppendFiles(zip,'c:/temp/someDir/*',recurse);
if (success == False) then
begin
Memo1.Lines.Add(CkZip__lastErrorText(zip));
Exit;
end;
// Setup the abort check callback.
// The HeartbeatMs property defines the number of milliseconds between AbortCheck callbacks.
CkZip_putHeartbeatMs(zip,25);
CkZip_SetAbortCheck(zip,MyAbortCheck);
// The MyAbortCheck function will be called from within CkZip_WriteZipAndClose
success := CkZip_WriteZipAndClose(zip);
if (success == False) then
begin
Memo1.Lines.Add(CkZip__lastErrorText(zip));
Exit;
end;
Memo1.Lines.Add('Zip Created!');
CkZip_Dispose(zip);
end;
admin
0
Tags :