给你一个简单例子吧。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Psock, NMSTRM, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
NMStrm1: TNMStrm;
NMStrmServ1: TNMStrmServ;
procedure Button1Click(Sender: TObject);
procedure NMStrmServ1MSG(Sender: TComponent; const sFrom: String;
strm: TStream);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
MyStream: TMemoryStream;
begin
try
MyStream:= TMemoryStream.Create;
MyStream.LoadFromFile('c:/a.dbf');
NMStrm1.PostIt(MyStream);
finally
MyStream.Free;
end;
end;
procedure TForm1.NMStrmServ1MSG(Sender: TComponent; const sFrom: String;
strm: TStream);
var
MyStream: TMemoryStream;
begin
try
MyStream := TMemoryStream.Create;
MyStream.LoadFromStream(strm);
MyStream.SaveToFile('c:/b.dbf');
finally
MyStream.Free;
end;
end;
end.