uses lyhClasses, lyhTools;
procedure TForm1.Button1Click(Sender: TObject);
var
F : HFILE;
P : PChar;
m : THandle;
s : Int64;
begin
s := Int64(GetSystemInfoEx.dwAllocationGranularity) * 102400;
F := CreateFile('C:\Demo.dat', GENERIC_ALL, FILE_SHARE_READ,
nil, OPEN_ALWAYS, FILE_FLAG_SEQUENTIAL_SCAN or FILE_FLAG_RANDOM_ACCESS, 0);
m := CreateFileMapping(F, nil, PAGE_READWRITE, 2, MaxInt, nil);
//RaiseLastOSError;
p := MapViewOfFile(m, FILE_MAP_ALL_ACCESS, Int64Rec(s).Hi, Int64Rec(s).Lo, 102);
//RaiseLastOSError;
P^ := 'a';
UnmapViewOfFile(p);
CloseHandle(m);
S := S + 102;
SetFilePointer(F, Int64Rec(s).Lo, @Int64Rec(s).Hi, soFromBeginning);
SetEndOfFile(F);
CloseHandle(F);
end;