C语言:进程的定义和CreateProcess函数
来源:优易学  2011-11-2 14:14:54   【优易学:中国教育考试门户网】   资料下载   IT书店

 

  //将该结构中的所有成员初始化为零,然后将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.

上一页  [1] [2] [3] 下一页

责任编辑:小草

文章搜索:
 相关文章
热点资讯
资讯快报
热门课程培训