J
janb
Unregistered / Unconfirmed
GUEST, unregistred user!
type
PClientInfo =^TClientInfo;
TClientInfo =Packed Record
Client_Name: String;
CLient_Index: Integer;
CLient_IP : String;
end;
var ClientInfo: array[0..9] of TClientInfo;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
test:file;
const filename:string='test.txt';
begin
if fileexists(filename) then
begin
AssignFile(test,filename);
Reset(Test,1);
BlockRead(test,ClientInfo[1],sizeof(TClientInfo));
CloseFile(test);
end
else
begin
ClientInfo[0].Client_Name :='test';
ClientInfo[0].CLient_Index :=1;
ClientInfo[0].CLient_IP :='222.1.6.169';
ASSignFile(test,filename);
Rewrite(test,1);
BlockWrite(test,ClientInfo[0],sizeof(TClientInfo));
reset(test,1);
BlockRead(test,ClientInfo[1],sizeof(TClientInfo));
CloseFile(test);
end;
Edit1.Text:=format('%s',[ClientInfo[1].CLient_Name]);
Edit2.Text:=Format('%d',[ClientInfo[1].Client_Index]);
Edit3.Text:=Format('%s',[clientInfo[1].Client_IP]);
end;
当程序不是第一次运行时,从文件test里取不到记录,请问这是为什么?