获取子进程的退出码“编程开发”
#include "stdafx.h" #include "windows.h" #include "iostream" using namespace std; int _tmain(int argc, _TCHAR* argv[]) { LPCTSTR lpName(_T("zzc")); LPCTSTR lpValue(_T("88888")); //设置环境变量的值 ::SetEnvironmentVariable(lpName,lpValue); STARTUPINFO si; PROCESS_INFORMATION pi; ZeroMemory(&si, sizeof(si)); ZeroMemory(&pi, sizeof(pi)); if( !CreateProcess( _T("D:\\绘图编程\\父子进程通信-环境变量\\Child\\Debug\\Child.exe"), NULL, NULL, NULL, TRUE, CREATE_NEW_CONSOLE/*DETACHED_PROCESS*/,//新进程使用自己的可控制台窗口 NULL, NULL, &si, &pi) ) { cout <<"shibai" <
#include "stdafx.h" #include "windows.h" #include "iostream" using namespace std; int _tmain(int argc, _TCHAR* argv[]) { LPCTSTR lpName(_T("zzc")); int nlength = ::GetEnvironmentVariable(lpName,NULL,0); LPTSTR lpValue = new TCHAR[nlength+1]; memset(lpValue,'\0',nlength+1); ::GetEnvironmentVariable(lpName,lpValue,nlength+1); setlocale(LC_ALL, "chs"); _tprintf(lpValue); cout <<>