欢迎光临
我们一直在努力

程序间相互通讯问题的解决_delphi教程

建站超值云服务器,限时71元/月

       在制作一个小程序的过程中,遇到程序间通讯的问题,而且两个程序分别是用pb跟delphi开发的,查阅网上资料,根据程序对于响应时间的要求,我选择了postmessage函数来解决通讯问题,代码如下



pb:


  string ls_Classname,ls_WindowName
    ulong ll_winhandle
  uint  li_result
    setnull(ls_ClassName)
    ls_WindowName =”Form1″ //delphi程序窗口名称
    ll_winhandle = findwindow(ls_ClassName,ls_WindowName)


if ll_winhandle>0 then //拨通
  li_result = RegisterWindowMessage(1111) //注册系统消息,返回系统唯一消息号


  post(ll_winhandle,li_result,0,0)
  messagebox(“提示”,”知道”)
else
 messagebox(“提示”,”没有找到”)
end if


======================================


delphi:


声明部分:


private
    Msg: LongInt;
    hWndC : THandle;
    { Private declarations }
  protected
    procedure WndProc(var Message: TMessage); override;


procedure TForm1.FormCreate(Sender: TObject);
begin
  Msg := RegisterWindowMessage(1111);//返回系统唯一消息号,1111为自定义消息内容
  Self.BringToFront;


end;


procedure TForm1.WndProc(var Message: TMessage);
 var
   mypt:Tpoint;
   s:string;
begin


  if Message.msg = msg then begin
      ShowMessage(inttostr(message.lparam) );
     end ;



    inherited;
 end;

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 程序间相互通讯问题的解决_delphi教程
分享到: 更多 (0)