Redirect stdout to an edit control (Win32)

后端 未结 3 399
终归单人心
终归单人心 2020-12-06 03:14

I have a simple Win32 GUI app which has an edit control in the main window. If I write:

printf(\"Hello world!\\n\");

I would like the text

3条回答
  •  天涯浪人
    2020-12-06 04:18

    You can do that in Windows by redirecting stdout when you create the process. You do so by setting flags and setting some handles in the STARTUPINFO structure passed to CreateProcess. See this example on MSDN for detail on how to set this up.

    Once you have that setup can use ReadFile to read from the redirected stdout of the console process then send it to the edit control.

提交回复
热议问题