在 VB6 应用程序和 .Net 应用程序之间传递数据
我需要在 vb6 应用程序和 .net 应用程序之间传递数据。该数据每秒都会被写入或读取。大约有30个字段。两个应用程序都驻留在同一台计算机上。我目前正在通过注册表传递这些数据,效果很好,但让我有点紧张。我会用文本文件来完成,但我担心数据丢失。
最好的方法是什么?
I need to pass data between a vb6 app and a .net app. This data will either be written or read every second. It is about 30 fields. Both apps reside on the same machine. I am currently passing this data via the registry and it works great but it makes me a little nervous. I would do it with a text file but I am worried about data loss.
What is the best way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您想轻松地做到这一点,我建议您使用某种 RPC 进程来共享信息。
最简单的可能是 XML-RPC
VB6 和 .Net 似乎两者都有必要的库。
如果您担心数据丢失,您也可以连接到同一数据库。
I'd recommend using some sort of RPC process to share the information if you want to do this easily.
The easiest one would probably be XML-RPC
VB6 and .Net seem to both have the necessary libraries.
You could also connect to the same database if you're worried about data loss.
通用后端?是的,注册表可以工作,文本文件也可以工作,但在多用户环境中,您最好使用数据库(例如 MS Access 或 SQL Server)。
Common back end? Yes, the registry works, text file will work, but in a multi-user environment, you're better off with a database (MS Access or SQL Server, for example.)
实际上,邮槽在机器之间也可以正常工作。尽管它们对于超过 400 字节的消息效果不佳。
DDE 仍然受支持,并且速度相当快。但可能没有 .Net 支持。
当然,简单的进程外 COM 只是 Windows RPC 之上的一个薄层。
Actually Mailslots work fine between machines too. Though they don't work well for messages much over 400 bytes.
DDE is still supported too, and is quite fast. Probably no .Net support however.
And of course simple out-of-process COM is just a thin layer on top of Windows RPC.
选择你的毒药:邮槽、内存映射文件、命名管道、套接字。网络上有大量的帮助和代码。
同一台计算机(均为 Windows 操作系统)上的进程之间的小消息:使用 MailSlots。
同一台机器上的进程之间的大数据块:使用内存映射文件。
在进程之间(相同或不同的计算机,均为 Windows 操作系统)传输消息:使用命名管道。
在进程之间(相同或不同的机器,相同或不同的操作系统)传输消息:使用套接字。
由于您现在正在使用注册表,也许可以使用 Mailslots。
Pick your poison: Mailslots, Memory-mapped files, Named Pipes, Sockets. There's plenty of help and code on the web for these.
Small messages between processes on the same machine (both Windows OS): Go with MailSlots.
Large blocks of data between processes on the same machine: Go with Memory-mapped files.
Streaming messages between processes (same or different machines, both Windows OS): Go with Named Pipes.
Streaming messages between processes (same or different machines, same or different OS's): Go with Sockets.
Since you're using the registry now, maybe Mailslots instead.