是否可以连接或调用现有流程?
在 Windows 中,我目前有两个程序运行如下。程序 A 使用一些参数调用程序 B,这会导致程序 B 返回一些文本然后退出。程序A再次使用其他参数调用程序B,这会导致程序B做更多的事情。
当程序B启动时,它需要做一些耗时的加载。上述方法意味着程序B必须加载两次。是否可以只加载程序B一次?
例如,程序A使用一些参数调用程序B,这导致程序B返回一些文本,但程序继续运行。程序A再次调用同一个进程,这会导致程序B做更多的事情。
或许使用某种 Windows 消息传递,上述可能吗?程序A是一个Delphi应用程序,使用Windows的CreateProcess方法。程序 B 是一个 .NET 应用程序,它根据传入的参数执行各种操作。我知道我们可以通过将程序 B 安装为 Windows 服务来完成此操作,但如果可能的话,我想避免这样做。
In Windows, I currently have two programs working as follow. Program A calls Program B with some parameters, which causes Program B to return some text then exits. Program A calls Program B again with other parameters, which causes Program B to do more things.
When Program B starts, it needs to do some time consuming loading. The method above means Program B has to do the loaded twice. Is it possible to load Program B only once?
e.g. Program A calls Program B with some parameters, which causes Program B to return some text, but the program continues to run. Program A calls the same process again, which causes Program B to do more things.
Is the above possible, perhaps using some sort of Windows messenging? Program A is a Delphi app, uses Windows' CreateProcess method. Program B is a .NET app that does various things according to the parameters passed in. I know we can do this by installing Program B as a Windows service, but I would like to avoid that if possible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这就是进程间通信的技术。 .NET 有 WCF/webservices 等来做到这一点。该服务可以使用可执行文件(甚至控制台应用程序)或作为 Windows 服务托管。您也可以选择网络服务器 (IIS)。
由于您的程序 B 位于 .NET 中,因此您可以将其作为服务托管并在 Delphi 应用程序中使用它。我不知道出于什么目的,您希望避免它的服务。但这肯定会给你带来优势,而且实现起来相当简单。
即使您使用 C/C++ 等,您也可以考虑使用 gSOAP 等包装器将程序 B 作为 Web 服务提供服务。
Here comes the technologies for inter process communication. .NET has WCF/webservices etc to do this. The service can be hosted using an executable (even a console app) or as an windows service. You can choose the webserver (IIS) also.
As your program B is in .NET, you can host it as a service and consume it in Delphi application. I don't know for what purpose, you wish to avoid it a a service. But this will positively give you an upper hand and the implementation is fairly simple.
Even in case you are using C/C++ etc, you can think of serving the program B as an webservice using wrappers like gSOAP.
我们最终创建了程序 B,它具有不可见的形式,因此它可以连续运行。每当程序 A 需要完成工作时,它都会向程序 B 发送一条 Windows 消息。当程序A退出时,它向程序B发送一条“退出”消息,程序B看到该消息并退出。
We ended up creating Program B that has an invisible form so it runs continously. Program A sends a Windows message to Program B whenever it needs work to be done. When Program A quits, it sends a 'Quit' message to Program B, Program B sees the message and quits as well.