// 01CreateProcess.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<windows.h>
#include<stdio.h>
int main(int argc, char* argv[])
{
printf("Hello World!/n");
char szCommand[] = "cmd";
STARTUPINFO si = {sizeof(si)};
PROCESS_INFORMATION pi ;
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = TRUE;
BOOL Rect = ::CreateProcess(NULL,
szCommand,
NULL,
NULL,
FALSE,
CREATE_NEW_CONSOLE,
NULL,
NULL,
&si,
&pi);
if(Rect)
{
::CloseHandle(pi.hThread);
::CloseHandle(pi.hProcess);
printf("%2d",pi.dwProcessId);
printf("/n");
printf("%2d",pi.dwThreadId);
}
return 0;
}