有点疑问,请帮助看看
type
datarecord=record
data1:real;
data2:integer;
end;
pdatarecord=^datarecord;
.........
procedure form1.buttonclick(sender:object);
var
shandle,maphandle:THandle;
fsize,startpos,mapsize,blocksize:candinal;
i:integer;
pshare:pdatarecord;
begin
if opendialog1.execute then
shandle:=fileopen(opendialog1.filename,fmopenread);
fsize:=getfilesize(shandle,nil);
maphandle:=createfilemapping(shandle,PAGE_READONLY,0,fsize,nil) //创建映射
closehandle(shandle);
startpos:=0;
mapsize:=blocksize*10; //blocksize是系统粒度64kb
while startpos<fsize do
begin
if startpos+blocksize*10>fsize then
mapsize:=fsize-startpos;
pshare:=mapviewoffile(maphandle,FILE_MAP_READ,0,startpos,mapsize);
for i:=1 to mapsize do
begin
memo1.lines.add(format('%5.2f',[pshare^.data1]));
inc(pshare); ///??? end; //for end
startpos:=startpos+mapsize;
unmapviewoffile(pshare) ;
end; //while end
closehandle(maphandle);
end;
有大概20M的数据,inc(pshare)让指针在记录里移动,为什么一块数据都读不完,就出错了,大家个看看,这里怎么写呀??
[解决办法]
inc(pshare) 可以设置指针移到?
[解决办法]
自己调试,或者把每步的指针位置打印,估计是位置错了,到了不可访问的地方