Q
qiangyao
Unregistered / Unconfirmed
GUEST, unregistred user!
[!]
这是我读取文件,但是返回的BUFFER为' '
procedure TForm1.Button1Click(Sender: TObject);
var
; iFileHandle: integer;
; iFileLength: integer;
; iBytesRead: integer;
; Buffer: PChar;
; i: longInt;
begin
; if OpenDialog1.Execute then
; begin
; ; try
; ; ; iFileHandle := FileOpen(OpenDialog1.FileName, fmOpenRead);
; ; ; iFileLength := FileSeek(iFileHandle,0,2);
; ; ; FileSeek(iFileHandle,0,0);
; ; ; Buffer := PChar(AllocMem(iFileLength + 1));
; ; ; iBytesRead := FileRead(iFileHandle, Buffer, iFileLength);
; ; ; FileClose(iFileHandle);
; ; ; for i := 0 to iBytesRead-1 do
; ; ; begin
; ; ; ; StringGrid1.RowCount := StringGrid1.RowCount + 1;
; ; ; ; StringGrid1.Cells[1,i+1] := Buffer;
; ; ; ; StringGrid1.Cells[2,i+1] := IntToStr(Integer(Buffer));
; ; ; end;
; ; finally
; ; ; FreeMem(Buffer);
; ; end;
; end;
end;
.
这是我读取文件,但是返回的BUFFER为' '
procedure TForm1.Button1Click(Sender: TObject);
var
; iFileHandle: integer;
; iFileLength: integer;
; iBytesRead: integer;
; Buffer: PChar;
; i: longInt;
begin
; if OpenDialog1.Execute then
; begin
; ; try
; ; ; iFileHandle := FileOpen(OpenDialog1.FileName, fmOpenRead);
; ; ; iFileLength := FileSeek(iFileHandle,0,2);
; ; ; FileSeek(iFileHandle,0,0);
; ; ; Buffer := PChar(AllocMem(iFileLength + 1));
; ; ; iBytesRead := FileRead(iFileHandle, Buffer, iFileLength);
; ; ; FileClose(iFileHandle);
; ; ; for i := 0 to iBytesRead-1 do
; ; ; begin
; ; ; ; StringGrid1.RowCount := StringGrid1.RowCount + 1;
; ; ; ; StringGrid1.Cells[1,i+1] := Buffer;
; ; ; ; StringGrid1.Cells[2,i+1] := IntToStr(Integer(Buffer));
; ; ; end;
; ; finally
; ; ; FreeMem(Buffer);
; ; end;
; end;
end;
.