我有以下代码。我正在尝试对 buf 指向的数据进行计算。
buf:PByteArray
inmem,outmem:TmemoryStream;
...
size := GetFileSize(aFile, nil);
buf := MapViewOfFile(map, FILE_MAP_READ, 0, 0, 0);
inmem.SetSize(size);
inmem.Position := 0;
//buf to memorystream
inmem.Write(buf[0], size);
outmem := tmemorystream.Create;
outmem.SetSize(size);
//Do memory stream processing
ProcMemoryStreams(inmem,outmem,size);
//
outmem.Position:=0;
//memorystream to buf
outmem.Read(buf[0],size); <-Access violation
我究竟做错了什么?