简体   繁体   English

如何在C ++中运行应用程序并写入其stdin并在Windows中从其stdout读取

[英]how to run an application in c++ and write to its stdin and read from its stdout in windows

I want to run an application in c++ and read its stdout and write t stdin in windows? 我想在C ++中运行应用程序并读取其stdout并在Windows中编写t stdin吗? No popup should be generated. 不应生成任何弹出窗口。

Can I do it easily using windows services? 我可以使用Windows服务轻松做到吗?

I found that I maybe able to do this with POCO, but do I really need this? 我发现我也许可以用POCO做到这一点,但是我真的需要吗?

Is there solution in std library for this? 在标准库中有解决方案吗?

You can spawn a child process and then gain access to its stdin and stdout pipes. 您可以生成一个子进程,然后访问其stdin和stdout管道。 You have to use WinAPI to achieve this. 您必须使用WinAPI来实现。 See example here: http://msdn.microsoft.com/en-us/library/ms682499(v=vs.85).aspx 请参阅此处的示例: http : //msdn.microsoft.com/zh-cn/library/ms682499(v=vs.85).aspx

You may use Qt and it's QProcess class to read/write child process output/input. 您可以使用Qt及其QProcess类来读取/写入子进程的输出/输入。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM