Var _ReadFile, _WriteFile, _Pending: Int64;
Function CPUTimeStampCounter: Int64;
ASM {$IFDEF DELPHI_5_UP} RDTSC
{$ELSE} DW $310F
{$ENDIF} End;
ZeroMemory(@O, SizeOf(TOverlapped));
O.hEvent := CreateEvent(
nil, False
{True}, False,
nil);
{} _ReadFile:=0; _WriteFile:=0; _Pending:=0;
...
{} _ReadFile:=_ReadFile-CPUTimeStampCounter;
ReadFile(Source, Buffer, W2, @W3,
nil);
{} _ReadFile:=_ReadFile+CPUTimeStampCounter;
O.InternalHigh := 0;
// reset OverlappedResult
O.Offset := LARGE_INTEGER(FilePos).LowPart;
O.OffsetHigh := LARGE_INTEGER(FilePos).HighPart;
//ResetEvent(O.hEvent);
{} _WriteFile:=_WriteFile-CPUTimeStampCounter;
WriteFile(Ho, Buffer, W2,
nil, @O);
{} _WriteFile:=_WriteFile+CPUTimeStampCounter;
MD5Update(MD5, Buffer, W);
CRC32Update(CRC32, Buffer, W);
{} _Pending:=_Pending-CPUTimeStampCounter;
While O.Internal = STATUS_PENDING
do Sleep(0);
{} _Pending:=_Pending+CPUTimeStampCounter;
If GetOverlappedResult(Ho, O, W3, True)
and (W3 <> W2)
Then
Exception(612, [DestName, IntToStrF(Part + 1), LastErrorMessage]);
...
{} Exception(997, [_ReadFile, _WriteFile, _Pending);