如何在 c++ 中运行应用程序并写入其标准输入并从 Windows 中的标准输出读取 [英] how to run an application in c++ and write to its stdin and read from its stdout in windows

查看:46
本文介绍了如何在 c++ 中运行应用程序并写入其标准输入并从 Windows 中的标准输出读取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 c++ 中运行一个应用程序并读取它的 stdout 并在 windows 中写入 t stdin?不应生成弹出窗口.

I want to run an application in c++ and read its stdout and write t stdin in windows? No popup should be generated.

我可以使用 Windows 服务轻松完成吗?

Can I do it easily using windows services?

我发现我也许可以用 POCO 做到这一点,但我真的需要它吗?

I found that I maybe able to do this with POCO, but do I really need this?

标准库中有解决方案吗?

Is there solution in std library for this?

推荐答案

您可以生成子进程,然后访问其 stdin 和 stdout 管道.您必须使用 WinAPI 来实现这一点.请参见此处的示例:http://msdn.microsoft.com/en-us/library/ms682499(v=vs.85).aspx

You can spawn a child process and then gain access to its stdin and stdout pipes. You have to use WinAPI to achieve this. See example here: http://msdn.microsoft.com/en-us/library/ms682499(v=vs.85).aspx

你可以使用 Qt 和它的 QProcess 类来读/写子进程的输出/输入.

You may use Qt and it's QProcess class to read/write child process output/input.

这篇关于如何在 c++ 中运行应用程序并写入其标准输入并从 Windows 中的标准输出读取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆