2 * PROJECT: ReactOS Automatic Testing Utility
3 * LICENSE: GNU GPLv2 or any later version as published by the Free Software Foundation
4 * PURPOSE: Class able to create a new process and closing its handles on destruction (exception-safe)
5 * COPYRIGHT: Copyright 2009 Colin Finck <colin@reactos.org>
11 * Constructs a CProcess object and uses the CreateProcessW function to start the process immediately.
14 * A std::wstring containing the command line to run
17 * Pointer to a STARTUPINFOW structure containing process startup information
19 CProcess::CProcess(const wstring
& CommandLine
, LPSTARTUPINFOW StartupInfo
)
21 auto_array_ptr
<WCHAR
> CommandLinePtr(new WCHAR
[CommandLine
.size() + 1]);
23 wcscpy(CommandLinePtr
, CommandLine
.c_str());
25 if(!CreateProcessW(NULL
, CommandLinePtr
, NULL
, NULL
, TRUE
, NORMAL_PRIORITY_CLASS
, NULL
, NULL
, StartupInfo
, &m_ProcessInfo
))
26 TESTEXCEPTION("CreateProcessW failed\n");
30 * Destructs a CProcess object and closes all handles belonging to the process.
34 CloseHandle(m_ProcessInfo
.hThread
);
35 CloseHandle(m_ProcessInfo
.hProcess
);