uses System;
//.....var F: TextFile;
S: string;
begin
if OpenDialog1.Execute then { Display Open dialog box }
begin
AssignFile(F, OpenDialog1.FileName); { File selected in dialog box }
Reset(F);
Readln(F, S); { Read the first line out of the file }
Edit1.Text := S; { Put string in a TEdit control }
CloseFile(F);
end;
end;在delphi中还可以uses Sysutils;procedure TForm1.Button1Click(Sender: TObject);var
iFileHandle: Integer;
iFileLength: Integer;
iBytesRead: Integer;
Buffer: PChar;
i: Integer
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[i];
StringGrid1.Cells[2,i+1] := IntToStr(Integer(Buffer[i]));
end;
finally
FreeMem(Buffer);
end;
end;
end;
//.....var F: TextFile;
S: string;
begin
if OpenDialog1.Execute then { Display Open dialog box }
begin
AssignFile(F, OpenDialog1.FileName); { File selected in dialog box }
Reset(F);
Readln(F, S); { Read the first line out of the file }
Edit1.Text := S; { Put string in a TEdit control }
CloseFile(F);
end;
end;在delphi中还可以uses Sysutils;procedure TForm1.Button1Click(Sender: TObject);var
iFileHandle: Integer;
iFileLength: Integer;
iBytesRead: Integer;
Buffer: PChar;
i: Integer
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[i];
StringGrid1.Cells[2,i+1] := IntToStr(Integer(Buffer[i]));
end;
finally
FreeMem(Buffer);
end;
end;
end;
解决方案 »
- ADOConnection1 连接 sql2000问题?
- 如何 将 两个表中的字段 显示在cxGrid的一个view中
- 朋友的一個問題,很長的程序...
- DELPHI中怎么画出带有箭头的线来?高分相送
- MDI主窗体FormStyle:=bsNone,子窗体最大化子窗体不见了.
- 如何用字符串相加后做一个变量名来取出这个变量的值?
- 在一个三层结构中,如何在应用程序服务器端得知目前连接上的客户端的数目,及其IP地址(SocketConnection连接)?
- 殷切恳求求帮助!!!怎样调试CLASS!!
- 请教,在SQL-Server中怎样将生成的大量数据快速存储,急!急!急!急!急!
- delphi上的控件板能不能快速切换?如何做?
- to GOHKI(豪鬼) 你试过了吗? 根本不行
- 请问高手,我在一个没有窗体的unit中写个生成窗体的过程,其中事件调用本unit中其他过程,但编译不了,为何?谢谢,哪个unit作为主程序调用的
Reset,Rewrite,Append
read,readln,write,writeln
CloseFile