K
Kirste
Unregistered / Unconfirmed
GUEST, unregistred user!
请帮忙看看下面这段代码哪出错了?编译后在Windows2000 下运行很正常,可Windows98下运行
却常出内存错误(Delphi6.0+Windows2000),谢谢啦!!!
谢谢每位看完代码的人。
却常出内存错误(Delphi6.0+Windows2000),谢谢啦!!!
代码:
function Getbm(Text:String):String;
var
bmVal,RetVal: integer;
MemMapFile:TMemMapFile;// 用来文件的内存映射
SearchRec:TSearchRec;
FoundStr:pchar;
FName:String;
begin
FoundStr:=nil;
RetVal:=FindFirst(ExtractFilePath(Paramstr(0))+'*.bm',faAnyFile,SearchRec);
try
while (RetVal=0) and (FoundStr=nil) do
begin
FName:=ExtractFilePath(Paramstr(0))+SearchRec.Name;
bmVal:=StrToInt(ExtractFileName(FName)[1]);
MemMapFile:=TMemMapFile.Create(FName,fmOpenRead,0,True);//将查找到的文件内存映射
try
FoundStr:=StrPos(Pchar(MemMapFile.Data),Pchar(Text));//错误应该是在这行,因为如果我注释掉这行就正常
Result:=copy(StrPas(FoundStr),1,bmVal+Length(Text));
RetVal:=FindNext(SearchRec);
finally
MemMapFile.Free;
end;
end;
finally
FindClose(SearchRec);
end;
end;