Merge branch 'master' of git@git.labs.intellij.net:idea/community
[fedora-idea.git] / native / VistaUpdaterLauncher / VistaUpdaterLauncher / VistaUpdaterLauncher.cpp
blobdd2e41980873351a2f9cb7a7c465ecc4630ce675
1 /*
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.
17 #include "stdafx.h"
18 #include <windows.h>
19 #include <process.h>
20 #include <stdio.h>
21 #include <tchar.h>
22 #include <conio.h>
23 #include <string.h>
24 #include <stdlib.h>
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);
46 fflush(stdout);
48 if (!CreateProcess(
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());
61 return -1;
64 WaitForSingleObject(processInformation.hProcess, INFINITE);
66 DWORD exitCode = 0;
67 if (!GetExitCodeProcess(processInformation.hProcess, &exitCode))
69 wprintf(L"Cannot retrieve process exit code: %d\n", GetLastError());
70 exitCode = -1;
72 CloseHandle(processInformation.hProcess);
74 return exitCode;