C++下的跨进程交互
请帮忙,我如何组织进程间数据交换(在 Windows 中,如果这很重要)?
我有 process1.exe
,它使用一些命令行参数调用 process2.exe
。我想从 process1
跟踪 process2
的“进度”(例如,一些 int
值)。它(该 int
值)可以从 process1
永久访问或每 X 毫秒访问 - 无关紧要。
任何解决方案都会有用:WinApi 或 Qt。
谢谢大家!所有答案都非常有用! :) 非常感谢!!
Please help, how can I organize the process-process data exchange (in Windows, if that matters)?
I have process1.exe
which calls process2.exe
with a few command line arguments. I want to track "progress" of process2
from process1
(say, some int
value). It (that int
value) can be accessed from process1
permanently or each X ms - doesn't matter.
Will be useful any solution: WinApi or Qt.
Thank you everybody! All answers are very useful! :) Many thanks!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
OTOH:
选择一个 - Windows 消息或共享内存可能更容易。
OTOH:
Pick one - Windows messages or shared memory may be the easier ones.
这里有很多选项:
There are many options here:
有几种方法:
问题是 Process2 将进行广播,而 Process1 将进行侦听。 Process1 需要知道 Process2 何时完成以及完成的百分比。
我相信套接字将是更好的途径,但这取决于应用程序、开发进度和概念的熟悉程度。
There are several methods:
The issue is that Process2 will be broadcasting and Process1 will be listening. Process1 will need to know when Process2 is finished and maybe the percentage complete.
I believe Sockets would be the better route, but that depends on the application, development schedule and familiarity of concepts.
您可以简单地使用 Windows Api (SendMessage) 发送消息。
You can simply send messages with Windows Api (SendMessage).
到目前为止所提供的选项中一个明显的遗漏是COM。我期待着常见的“COM 是垃圾”的回应,但根据我的经验,情况并非如此。
An obvious omission in the options presented so far is COM. I'm expecting the usual flurry of "COM is crap" responses, but in my experience this hasn't been the case.