在发送程序中使用var mysend:tcopydatastruct; rhand:thandle;
begin
mysend.cbdata:=length(edit1.text)+1;
getmem(mysned.lpdata,mysend.cbdata);
strcopy(mysend.lpdata,pchar(edit1.text);
rhand:=findwindow(nil,'application2');
if rhand<>0 then
sendmessage(rhand,WM_COPYDATA,handle,cardinal(@mysend));
freemem(mysend.lpdata);
end;
在第二个程序中
procedure tform2.mymessage(var t:twmcopydata);
begin
edit1.text:=strpas(t.copydatastruct^.lpdata);
end;