2 * PROJECT: ReactOS Automatic Testing Utility
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Class that creates a process and redirects its output to a pipe
5 * COPYRIGHT: Copyright 2015 Thomas Faber (thomas.faber@reactos.org)
11 * Constructs a CPipedProcess object and starts the process with redirected output.
14 * A std::wstring containing the command line to run.
17 * The CPipe instance to redirect the process's output to.
18 * Note that only the read pipe is usable after the pipe was passed to this object.
20 CPipedProcess::CPipedProcess(const wstring
& CommandLine
, CPipe
& Pipe
)
21 : CProcess(CommandLine
, InitStartupInfo(Pipe
))
23 Pipe
.CloseWritePipe();
27 * Initializes the STARTUPINFO structure for use in CreateProcessW.
30 * The CPipe instance to redirect the process's output to.
33 CPipedProcess::InitStartupInfo(CPipe
& Pipe
)
35 ZeroMemory(&m_StartupInfo
, sizeof(m_StartupInfo
));
36 m_StartupInfo
.cb
= sizeof(m_StartupInfo
);
37 m_StartupInfo
.dwFlags
= STARTF_USESTDHANDLES
;
38 m_StartupInfo
.hStdInput
= GetStdHandle(STD_INPUT_HANDLE
);
39 m_StartupInfo
.hStdOutput
= Pipe
.m_hWritePipe
;
40 m_StartupInfo
.hStdError
= Pipe
.m_hWritePipe
;
41 return &m_StartupInfo
;