首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

有点疑问,请帮助看看,该如何解决

2012-02-14 
有点疑问,请帮助看看typedatarecordrecorddata1:realdata2:integerendpdatarecord^datarecord......

有点疑问,请帮助看看
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) 可以设置指针移到?
[解决办法]
自己调试,或者把每步的指针位置打印,估计是位置错了,到了不可访问的地方

热点排行