//将该结构中的所有成员初始化为零,然后将c b 成员设置为该结构的大小:SECURITY_ATTRIBUTES saProcess,saThread;
PROCESS_INFORMATION piProcessB,piProcessC;
TCHAR szPath[MAX_PATH];
//Prepare to spawn Process B from Process A.
//The handle identifying the new process
//object should be inheritable.
//准备从进程A中创建进程B
//saProcess.bInheritHandle = TRUE;
//标示表示新的进程能够被继承
saProcess.nLength = sizeof(saProcess);
saProcess.lpSecurityDescriptor = NULL;
saProcess.bInheritHandle = TRUE;
//The handle identifying the new thread
//object should NOT be inheritable.
//saThread.bInheritHandle = FALSE;
//这个标示线程不能被继承
saThread.nLength = sizeof(saThread);
saThread.lpSecurityDescriptor = NULL;
saThread.bInheritHandle = FALSE;
//Spawn Process B.
//创建进程B
lstrcpy(szPath,TEXT("ProcessB"));
CreateProcess(NULL,szPath, &saProcess,&saThread, FALSE,0,NULL,NULL,&si,
&piProcessB);
//The pi structure contains two handles
//relative to Process A:
//hProcess,which identifies Process B's process //object and is inheritable; and hThread,
//which identifies Process B's primary thread
//object and is NOT inheritable.
责任编辑:小草