开发者

How to send a short string from a Visual Basic application to a Delphi application?

I need to send a short string, (less than 30 bytes, but sent every second), from one VB applicatio开发者_StackOverflown, to a Delphi application.. is this possible, using CopyDataStruct, WM_COPYDATA and SendMessage functions in Windows?


I would say that WM_COPYDATA is the perfect way to do this. You just need to get your Delphi main form, say, to implement a message handler for WM_COPYDATA.

At the Delphi end it looks something like this:

TMyMainForm = class(TForm)
protected
  procedure WMCopyData(var Msg: TWMCopyData); message WM_COPYDATA;
end;

procedure TMyMainForm.WMCopyData(var Msg: TWMCopyData);
begin
  //do something with Msg.lpData
end;

Your VB code will need to obtain the window handle of your Delphi main form.


This sounds like the kind of thing that you would use DDE to accomplish. Another way would be to write a string into a temporary area in the registry and then call the other program to read it and delete the temporary registry key once finished. You could also pass the string as a parameter in the command line and just exec the program.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜