function TForm1.OnDiskRead(Sender: TObject; Buffer: Pointer; Length: DWORD; var BytesRead: DWORD; Offset: Int64): BOOL;
begin
if (Offset + Length <= (Sender as TFileDisk).FileStream.Size) then
begin
(Sender as TFileDisk).FileStream.Seek(Offset, TSeekOrigin.soBeginning);
BytesRead := (Sender as TFileDisk).FileStream.ReadData(Buffer, Length);
end
else
BytesRead := 0;
Result := True;
end;
function TForm1.OnDiskWrite(Sender: TObject; Buffer: Pointer; Length: DWORD; var BytesWritten: DWORD; Offset: Int64): BOOL;
begin
if (Offset + Length <= (Sender as TFileDisk).FileStream.Size) then
begin
(Sender as TFileDisk).FileStream.Seek(Offset, TSeekOrigin.soBeginning);
BytesWritten := (Sender as TFileDisk).FileStream.WriteData(Buffer, Length);
end
else
BytesWritten := 0;
Result := True;
end;