如何将短字符串从 Visual Basic 应用程序发送到 Delphi 应用程序?
我需要从一个 VB 应用程序向 Delphi 应用程序发送一个短字符串(小于 30 个字节,但每秒发送一次)。在 Windows 中使用 CopyDataStruct、WM_COPYDATA 和 SendMessage 函数可以吗?
I need to send a short string, (less than 30 bytes, but sent every second), from one VB application, to a Delphi application.. is this possible, using CopyDataStruct, WM_COPYDATA and SendMessage functions in Windows?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想说 WM_COPYDATA 是执行此操作的完美方法。例如,您只需要获取 Delphi 主窗体即可实现 WM_COPYDATA 的消息处理程序。
在 Delphi 端,它看起来像这样:
您的 VB 代码将需要获取 Delphi 主窗体的窗口句柄。
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:
Your VB code will need to obtain the window handle of your Delphi main form.
这听起来像是使用 DDE 来完成的事情。另一种方法是将字符串写入注册表中的临时区域,然后调用其他程序来读取它,并在完成后删除临时注册表项。您还可以在命令行中将字符串作为参数传递,然后执行程序。
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.