2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
27 int _tmain(int argc
, _TCHAR
* argv
[])
29 STARTUPINFO startupInfo
= {0};
30 startupInfo
.cb
= sizeof(startupInfo
);
31 PROCESS_INFORMATION processInformation
= {0};
33 startupInfo
.hStdInput
= GetStdHandle(STD_INPUT_HANDLE
);
34 startupInfo
.hStdOutput
= GetStdHandle(STD_OUTPUT_HANDLE
);
35 startupInfo
.hStdError
= GetStdHandle(STD_ERROR_HANDLE
);
37 wchar_t commandLine
[32768] = L
"";
39 for (int i
= 1; i
< argc
; i
++) {
40 wcscat_s(commandLine
, L
"\"");
41 wcscat_s(commandLine
, argv
[i
]);
42 wcscat_s(commandLine
, L
"\" ");
45 wprintf(L
"Creating new process: %s\n", commandLine
);
49 NULL
, /*LPCTSTR lpApplicationName*/
50 commandLine
,/* LPTSTR lpCommandLine*/
51 NULL
, /*LPSECURITY_ATTRIBUTES lpProcessAttributes*/
52 NULL
, /*LPSECURITY_ATTRIBUTES lpThreadAttributes*/
53 TRUE
, /*BOOL bInheritHandles,*/
54 0, /*DWORD dwCreationFlags*/
55 NULL
, /*LPVOID lpEnvironment*/
56 NULL
, /*LPCTSTR lpCurrentDirectory*/
57 &startupInfo
, /*LPSTARTUPINFO lpStartupInfo*/
58 &processInformation
/*LPPROCESS_INFORMATION lpProcessInformation*/))
60 wprintf(L
"Cannot create process: %d\n", GetLastError());
64 WaitForSingleObject(processInformation
.hProcess
, INFINITE
);
67 if (!GetExitCodeProcess(processInformation
.hProcess
, &exitCode
))
69 wprintf(L
"Cannot retrieve process exit code: %d\n", GetLastError());
72 CloseHandle(processInformation
.hProcess
);