{ FindWindow 的两个参数: 第一个: 是类名, 计算器的类名是: SciCalc 第二个: 是标题名 两个参数有其一即可,格式: } h := FindWindow('SciCalc', nil); h := FindWindow(nil, '计算器'); procedure SendMsg(AppName,Msg:string); var ds: TCopyDataStruct; handle:THandle; begin ds.cbData:=Length(Msg)+1; GetMem(ds.lpData,ds.cbData); try StrCopy(ds.lpData,PChar(Msg)); handle:=FindWindow(nil,Pchar(AppName)); handle:=FindWindow('TReceiveFrm',nil)); SendMessage(handle, WM_COPYDATA, 0, Integer(@ds)); finally FreeMem(ds.lpData,ds.cbData); end; end; { 调用:} SendMsg('Receie窗口','Hello World'); public procedure WMCopyData(var Msg: TWMCOPYDATA); message WM_COPYDATA; procedure TReceiveFrm.WMCopyData(var Msg: TWMCOPYDATA); begin showmessage(StrPas(Msg.CopyDataStruct^.lpData)); end;