J
jsxjd
Unregistered / Unconfirmed
GUEST, unregistred user!
读取一个正在进行读写的文件的内容!!
const MyFile='d:/ttt';
var
F:TFileStream;
procedure TForm1.FormCreate(Sender: TObject);
var
x:integer ;
begin
if not fileexists(MyFile) then
begin
F:=TFileStream.Create(MyFile,fmCreate);
F.free;
end;
F:=TFileStream.Create(MyFile,fmOpenReadWrite or fmShareDenyNone);
x:=1234;
f.WriteBuffer(x,4);
x:=5678;
f.WriteBuffer(x,4);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
f.free;
end;
//读取正下进行读写的文件内容
procedure TForm1.Button1Click(Sender: TObject);
var
AF:TFileStream;
x:integer;
begin
AF:=TFileStream.Create(MyFile,fmOpenRead or fmShareDenyNone);
af.Position:=0;
af.readBuffer(x,4);
showmessage(inttostr(x));
af.readBuffer(x,4);
showmessage(inttostr(x));
AF.free;
end;
//改变文件内容
procedure TForm1.Button2Click(Sender: TObject);
var
x:integer;
begin
f.position:=0;
x:=8888;
f.Write(x,4);
x:=9999;
f.Write(x,4);
end;
const MyFile='d:/ttt';
var
F:TFileStream;
procedure TForm1.FormCreate(Sender: TObject);
var
x:integer ;
begin
if not fileexists(MyFile) then
begin
F:=TFileStream.Create(MyFile,fmCreate);
F.free;
end;
F:=TFileStream.Create(MyFile,fmOpenReadWrite or fmShareDenyNone);
x:=1234;
f.WriteBuffer(x,4);
x:=5678;
f.WriteBuffer(x,4);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
f.free;
end;
//读取正下进行读写的文件内容
procedure TForm1.Button1Click(Sender: TObject);
var
AF:TFileStream;
x:integer;
begin
AF:=TFileStream.Create(MyFile,fmOpenRead or fmShareDenyNone);
af.Position:=0;
af.readBuffer(x,4);
showmessage(inttostr(x));
af.readBuffer(x,4);
showmessage(inttostr(x));
AF.free;
end;
//改变文件内容
procedure TForm1.Button2Click(Sender: TObject);
var
x:integer;
begin
f.position:=0;
x:=8888;
f.Write(x,4);
x:=9999;
f.Write(x,4);
end;