Execute a process and return its standard output in VC++

后端 未结 2 1385
渐次进展
渐次进展 2021-01-25 05:37

What\'s the easiest way to execute a process, wait for it to finish, and then return its standard output as a string?

Kinda like backtics in Perl.

Not looking fo

2条回答
  •  心在旅途
    2021-01-25 06:20

    WinAPI solution:

    You have to create process (see CreateProcess) with redirected input (hStdInput field in STARTUPINFO structure) and output (hStdOutput) to your pipes (see CreatePipe), and then just read from the pipe (see ReadFile).

提交回复
热议问题