Launching a sub-process under Windows Atom Feed 0

In Brief The minimum code needed to launch a sub-process under Win32.
# 's
 1#include <stdio.h>
2#include <tchar.h>
3#include <windows.h>
4
5int _tmain(int argc, _TCHAR* argv[])
6{
7 if (argc < 2)
8 {
9 printf("Specify a program to launch\n");
10 return 0;
11 }
12
13 // Initialize StartupInfo structure
14 STARTUPINFO StartupInfo;
15 memset(&StartupInfo, 0, sizeof(StartupInfo));
16 StartupInfo.cb = sizeof(StartupInfo);
17
18 // This will contain the information about the newly created process
19 PROCESS_INFORMATION ProcessInformation;
20
21 BOOL results = CreateProcess(0,
22 argv[1],
23 0, // Process Attributes
24 0, // Thread Attributes
25 FALSE, // Inherit Handles
26 0, // CreationFlags,
27 0, // Enviornment
28 0, // Current Directory
29 &StartupInfo, // StartupInfo
30 &ProcessInformation // Process Information
31 );
32 if (!results)
33 {
34 printf("Failed to launch process");
35 return -1;
36 }
37
38 // Cleanup
39 CloseHandle(ProcessInformation.hProcess);
40 CloseHandle(ProcessInformation.hThread);
41 return 0;
42}

The minimum code needed to launch a sub-process under Win32.