result:=True;
FFileHandle:=fileopen(filename,fmopenreadwrite);
if FFileHandle=invalid_handle_value then
begin
//raise exception.Create('failed to open or create file');
result:=False;
end;
try
FFilesize:=Windows.GetFileSize(FFileHandle,nil);
FMapHandle:=createfilemapping(Ffilehandle,nil,Page_readwrite,0,FFilesize,nil);
if FMapHandle=0 then
BEGIN
//raise exception.Create('failed to create file mapping');
result:=False;
END;
finally
closehandle(FFileHandle);
end;
try
Fdata:=mapviewoffile(FMapHandle,file_map_all_access,0,0,ffilesize);
if fdata=nil then
BEGIN
//raise exception.Create('failed to map view of file ');
result:=False;
END;
finally
closehandle(FMapHandle);
end;
memStream := TmemoryStream.Create;
memStream.LoadFromFile(filename);