function RandomSystemTime: Cardinal;
// create Seed from Systemtime and PerformanceCounter
type
TInt64Rec =
packed record
Lo, Hi: LongWord;
end;
var
{$IFDEF MSWINDOWS}
SysTime: TSystemTime;
{$ELSE}
Hour, Minute, Second, Milliseconds: Word;
{$ENDIF MSWINDOWS}
Counter: TInt64Rec;
Time: Cardinal;
begin
{$IFDEF MSWINDOWS}
GetSystemTime(SysTime);
Time := ((Cardinal(SysTime.wHour) * 60 + SysTime.wMinute) * 60 + SysTime.wSecond) * 1000 + SysTime.wMilliseconds;
QueryPerformanceCounter(Int64(Counter));
{$ELSE}
DecodeTime(Now, Hour, Minute, Second, Milliseconds);
Time := ((Cardinal(Hour) * 60 + Minute) * 60 + Second) * 1000 + Milliseconds;
Int64(Counter) := TStopwatch.GetTimeStamp;
// uses System.Diagnostics
{$ENDIF MSWINDOWS}
Result := Time + Counter.Hi;
Inc(Result, Ord(Result < Time));
// add "carry flag"
Inc(Result, Counter.Lo);
end;
function DoRndBuffer(Seed: Cardinal;
var Buffer; Size: Integer): Cardinal;
// comparable to Borlands Random() function
var
P: PByte;
begin
Result := Seed;
P := @Buffer;
if P <>
nil then
begin
while Size > 0
do
begin
Result := Result * $08088405 + 1;
P^ := Byte(Result
shr 24);
Inc(P);
Dec(Size);
end;
end;
end;