View Code #include "stdafx.h" #include <windows.h> #include <iostream> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { WCHAR szCommandLine[] = _T("notepad.exe "); STARTUPINFO si = {sizeof(si)}; PROCESS_INFORMATION pi; BOOL bRet = ::CreateProcess(NULL, szCommandLine, NULL, NULL, FALSE, NULL, NULL, NULL, &si, &pi); if (bRet) { ::CloseHandle(pi.hProcess); ::CloseHandle(pi.hThread); cout<<"新进程的ID:"<<pi.dwThreadId<<endl; cout<<"新进程的主线程ID:"<<pi.dwProcessId <<endl; } return 0; }