#include "stdafx.h"
#include <windows.h>
int main(int argc, char* argv[])
{
//創建進程
char szCommandLine[]="cmd";
STARTUPINFO si={sizeof(si)};
PROCESS_INFORMATION pi;
si.dwFlags=STARTF_USESHOWWINDOW;
si.wShowWindow=true;
bool bRet=::CreateProcess(
NULL,
szCommandLine,
NULL,
NULL,
FALSE,
CREATE_NEW_CONSOLE,
NULL,
NULL,
&si,
&pi);
if(bRet)
{
::CloseHandle(pi.hThread);
::CloseHandle(pi.hProcess);
printf("新進程的進程ID號:%d\n",pi.dwProcessId);
printf("新進程的主線程的ID號:%d\n",pi.dwThreadId);
}
}