How can I redirect stdout to some visible display in a Windows Application?

后端 未结 8 1330
时光取名叫无心
时光取名叫无心 2020-11-27 03:31

I have access to a third party library that does \"good stuff.\" It issues status and progress messages to stdout. In a Console application I can see these messages just f

8条回答
  •  难免孤独
    2020-11-27 04:14

    When you create a process using CreateProcess() you can choose a HANDLE to which stdout and stderr are going to be written. This HANDLE can be a file to which you direct the output.

    This will let you use the code without recompiling it. Just execute it and instead of using system() or whatnot, use CreateProcess().

    The HANDLE you give to CreateProcess() can also be that of a pipe you created, and then you can read from the pipe and do something else with the data.

提交回复
热议问题