用内存映象文件吧。<br><br><br>unit memfileu;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> Button2: TButton;<br> Memo1: TMemo;<br> Button3: TButton;<br> procedure Button1Click(Sender: TObject);<br> procedure Button2Click(Sender: TObject);<br> procedure Button3Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br> RPtValue =record<br>// x,y:double;<br> Pt_id:integer;<br> pt_value:single;<br> pt_state:integer;<br>// pt_unit:string[10];<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br><br>//读memfile<br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> hMap:THandle;<br> data,d:^RPtValue;<br> i:integer;<br>begin<br> hMap:=CreateFileMapping(-1,nil,PAGE_READONLY,0,1024,'JZS_SHARE_MEMORY');<br> if hMap=NULL then exit;<br> data:=Mapviewoffile(hMap,FILE_MAP_READ,0,0,0);<br> d:=data;<br> for i:=0 to 25 do<br> begin<br> memo1.Lines.Add(inttostr(d^.Pt_id)+':'+floattostr(d^.pt_value)+':'+inttostr(d^.pt_state));<br> inc(d);<br> end;<br>end;<br><br>//创建/写memfile<br>procedure TForm1.Button2Click(Sender: TObject);<br>var<br> hFile:THandle;<br> hMapping:THandle;<br> data,d:^integer;<br> i:integer;<br>begin<br> hMapping:=CreateFileMapping($ffffffff,nil,PAGE_READWRITE ,0,1024,pchar('JZS_SHARE_MEMORY'));<br> data:=MapViewOfFile(hMapping,FILE_MAP_WRITE,0,0,0);<br><br> d:=data;<br> for i:=0 to 25 do<br> begin<br> d^:=ord('a')+i;<br> inc(d);<br> end;<br><br>end;<br><br>procedure TForm1.Button3Click(Sender: TObject);<br>var<br> r: RPtValue;<br>begin<br> showmessage(inttostr(sizeof(r)));<br>end;<br><br>end.<br><br>