//Prepare to spawn Process C from Process A.
//Since NULL is passed for the psaProcess and
//psaThread parameters,the handles to Process C's
//process and primary thread objects default
//to "noninheritable."
//If Process A were to spawn another process,
//this new process would NOT inherit handles
//to Process C's process and thread objects.
//Because TRUE is passed for the bInheritHandles
//parameter,Process C will inherit the handle that
//identifies Process B's process object but will
//not inherit a handle to Process B's primary
//thread object.
//PI结构体包含两个句柄
//并且关联到进程A中:
//被声明为可继承的进程B(hProcess),
//和被声明为不可继承的进程B的主线程(hThread)
//从进程A中创建进程C
//是通过一个空的psaProcess和一个空的psaThread参数
//所以进程C的进程和主线程是默认不可继承的
//如果进程A创建一个新的进程
//这个新的进程是不能继承进程C的进程和主线程的
//由于在创建进程C的时候CreateProcess的参数
//bInheritHandles被置为True,进程C将会继承进程B //的进程,但是不会进程进程B的主线程
lstrcpy(szPath,TEXT("ProcessC"));
CreateProcess(NULL,szPath,NULL,NULL, TRUE,0,NULL,NULL,&si,&piProcessC);
return(0);
}
责任编辑:小草