为什么我的这段文件读写代码老是报告内存错误?谢谢!
function  TForm2.ReadFile1(StrFilePath: PChar): PChar;
var
        iFileHandle: Integer;
        iFileLength: Integer;
        iBytesRead: Integer;
        Buffer: PChar;
        i: Integer  ;
        pp:Pchar;
        temp : String;
begin
        Result := nil;
        try
        iFileHandle := FileOpen(StrFilePath, fmOpenRead);//fmOpenReadWrite);
        if (iFileHandle < 0) then
        begin
                 Result := nil;
                 exit;
        end ;
        iFileLength := FileSeek(iFileHandle,0,2);
        FileSeek(iFileHandle,0,0);
        Buffer := PChar(AllocMem(iFileLength + 1));
        iBytesRead := FileRead(iFileHandle, Buffer, iFileLength);
        FileClose(iFileHandle);
        //ShowMessage(Buffer);
        Buffer[iFileLength+1]:=#0;
        Result:=Buffer;
        finally
                FreeMem(Buffer);
        end;end;