适用于 VB6 和 .net 应用程序的最佳 IPC

发布于 2024-07-16 06:41:50 字数 223 浏览 5 评论 0原文

在我们的应用程序(文档管理系统)中,我们应该收到屏幕更改的通知(或通知其他程序屏幕更改),以便使两个应用程序查看相同的数据,一个是订单履行应用程序,另一个是订单履行应用程序原始传真的文档查看器。 履行应用程序是用 vb6 编写的,文档管理器是用 .net 3.5 (c#) 编写的。 它在终端服务器上运行,因此它也必须具有会话意识。 文档查看器或履行应用程序可能会先打开,并且两者都可以单独使用。 IPC 的最佳方法是什么?

In our application (a document management system) we are supposed to be notified of screen changes (or notify the other program of screen changes) in order to keep the two applications looking at the same data, one being the order fulfillment app, the other the document viewer of the original fax. The fulfillment app is written in vb6 and the document manager is in .net 3.5 (c#). It runs on a terminal server so it also has to be session aware. The document viewer or the fulfillment app may be open first and both can be used without the other. What would be the best method of IPC?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

雅心素梦 2024-07-23 06:41:50

如果您希望能够在 Vista 或 Windows 7 上运行,IPC 的最佳形式将是 TCP(这可以通过 Winsock 控件在 VB6 中轻松完成)。

这样做的好处是两个应用程序可以通信,即使它们不是以同一用户身份运行,它们也可以通信(在 Vista+ 下不能使用 SendMessage 或命名管道来做到这一点)。 您唯一需要记住做的就是在防火墙中设置规则,这样它就不会被阻止。 这可以在您的安装程序中通过以下方式完成:

netsh.exe firewall set allowedprogram "{PROGRAM PATH}" "{PROGRAM NAME}" enable

If you want to be able to run on Vista or Windows 7, the best form of IPC is going to be TCP (which is done very easily from VB6 with the Winsock control).

The advantage of this is that two apps can communicate even if they aren't running as the same user, they can communicate (you can't do that with SendMessage or Named Pipes under Vista+). The only thing you have to remember to do, is set a rule in the firewall so it doesn't get blocked. This can be done in your installer with:

netsh.exe firewall set allowedprogram "{PROGRAM PATH}" "{PROGRAM NAME}" enable
千年*琉璃梦 2024-07-23 06:41:50

克里斯的答案可能仍然是最好的选择,但您可能需要拼凑才能保持终端服务器的理智。

在任何您想充当“服务器”应用程序的应用程序上,您都可以打开一个未使用的端口,并将其显示为要输入“客户端”应用程序。 甚至可能利用环境变量。 根据您的需求,这种方法可能完全错误。

如果您只有两个应用程序,其中一个应用程序需要在另一个应用程序发生更改时收到通知(而不通知实际更改的内容),那么您可以通过发送和挂钩 Windows 消息来实现这一点。

Kris's answer is probably still the best bet, but you would likely need a kludge to maintain sanity with terminal server.

On whichever application you want to act as the "server" app, you could open an unused port, and display it to be entered into the "client" app. Perhaps even utilizing environment variables. Depending on your needs, this approach could be all wrong.

If you simply have two apps where one needs to be notified when the other changes (and not notified of what actually changed), you could probably do it by sending and hooking windows messages.

陌若浮生 2024-07-23 06:41:50

命名管道和邮槽仍然是可用的最佳选择,并且它们可以跨用户和跨进程工作。 当然,在 Vista+ 中,以不同完整性级别运行的进程会存在问题,并且安全性也适用于早期操作系统 - 非常类似于文件安全性。

TCP 在同一台机器内总是显着慢,甚至可能比跨进程的 WM_COPYDATA 更​​慢。

使用管道或邮槽,您可以通过将会话 ID 作为名称的一部分来处理终端服务。 TCP 将始终受到其有限的端口号“命名空间”的挑战(想象一个硬盘驱动器只能包含名为 0 到 65535 的文件 - 每个连接需要两个端口号)。

Named pipes and mailslots are still some of the best choices available, and they work cross-user as well as cross-process. Of course in Vista+ there are issues with processes running at different integrity levels, and security applies on earlier OSs as well - much like file security.

TCP is always significantly slower within the same machine, probably even worse than WM_COPYDATA across processes.

Using pipes or mailslots you can handle terminal services by making the session ID part of the name. TCP will always be challenged by its limited "namespace" of port numbers (imagine a hard drive that can only have files named 0 through 65535 - and each connection requires TWO port numbers).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文