F
fsmei
Unregistered / Unconfirmed
GUEST, unregistred user!
从帮助抄的,都有错
procedure TForm1.Button1Click(Sender: TObject);
var iFileHandle: Integer
iFileLength: Integer
iBytesRead: Integer
Buffer: PChar;
begin
try
iFileHandle := FileOpen('c:/1.txt', fmOpenRead);
iFileLength := FileSeek(iFileHandle,0,2);
FileSeek(iFileHandle,0,0);
Buffer := PChar(AllocMem(iFileLength + 1));
iBytesRead := FileRead(iFileHandle, Buffer, iFileLength);
FileClose(iFileHandle);
finally
FreeMem(Buffer)
//////////出错信息Invalid pointer operation
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var iFileHandle: Integer
iFileLength: Integer
iBytesRead: Integer
Buffer: PChar;
begin
try
iFileHandle := FileOpen('c:/1.txt', fmOpenRead);
iFileLength := FileSeek(iFileHandle,0,2);
FileSeek(iFileHandle,0,0);
Buffer := PChar(AllocMem(iFileLength + 1));
iBytesRead := FileRead(iFileHandle, Buffer, iFileLength);
FileClose(iFileHandle);
finally
FreeMem(Buffer)
//////////出错信息Invalid pointer operation
end;
end;