服务程序
unit ddeserver;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, DdeMan, Buttons;
type
TForm1 = class(TForm)
ddesc: TDdeServerConv;
ddesi: TDdeServerItem;
Button2: TButton;
Edit1: TEdit;
Memo1: TMemo;
cccc: TBitBtn;
procedure Button2Click(Sender: TObject);
procedure ddesiPokeData(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button2Click(Sender: TObject);
begin
close;
end;
procedure TForm1.ddesiPokeData(Sender: TObject);
var
i:integer;
begin
if ddesi.Lines.Count<>0 then
begin
i:=ddesi.Lines.Count-1;
memo1.Lines.Add(ddesi.Lines
);
ddesi.Lines.Clear;
ddesi.Lines.Add(edit1.Text);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
ddesi.Lines.Add(edit1.text);
memo1.Clear;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
ddesi.Lines.Clear;
ddesi.Lines.add(edit1.text);
end;
end.
客户程序
unit ddeclient;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, DdeMan;
type
TForm1 = class(TForm)
Button1: TButton;
ddeci: TDdeClientItem;
ddecc: TDdeClientConv;
Edit1: TEdit;
Button2: TButton;
Button3: TButton;
Edit2: TEdit;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button2Click(Sender: TObject);
begin
close;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
aachar;
begin
edit1.Text:='';
ddecc.SetLink('pddeserver','ddesc');
aa:=StrAlloc(255);
ddecc.OpenLink;
aa:=ddecc.RequestData('ddesi');
ddecc.CloseLink;
if aa<>nil then
edit1.Text:=strpas(aa);
StrDisPose(aa);
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
ddecc.SetLink('pddeserver','ddesc');
// thedata := StrAlloc(79);
ddecc.OpenLink;
ddeci.Lines.Clear;
ddeci.Lines.Add(edit2.text);
ddecc.PokeDataLines(ddeci.DdeItem,ddeci.Lines);
ddecc.CloseLink;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
ddeci.DdeConv:=ddecc;
ddeci.DdeItem:='ddesi';
ddecc.ConnectMode:=ddeManual;
ddecc.DdeService:='pddeserver';
ddecc.DdeTopic:='ddesc';
ddecc.ServiceApplication:='';
end;
end.