CreateProcess

#include <windows.h>
#include <stdio.h>
#include <stdlib.h>

int  main()
{
 STARTUPINFO si = {sizeof(si)};

 SECURITY_ATTRIBUTES saProcess,saThread;
 PROCESS_INFORMATION piProcessB;

 TCHAR szPath1[MAX_PATH] = {TEXT("sub.exe")};
 TCHAR szPath2[MAX_PATH] = {TEXT("ProcessC")};

 saProcess.nLength = sizeof(saProcess);
 saProcess.lpSecurityDescriptor = NULL;
 saProcess.bInheritHandle = TRUE;

 saThread.nLength = sizeof(saThread);
 saThread.lpSecurityDescriptor = NULL;
 saThread.bInheritHandle = FALSE;

 
 CreateProcess(NULL,szPath1,&saProcess,&saThread,FALSE,CREATE_SUSPENDED |DETACHED_PROCESS ,NULL,NULL,&si,&piProcessB);
// CreateProcess(NULL,szPath1,&saProcess,&saThread,FALSE,CREATE_SUSPENDED ,NULL,NULL,&si,&piProcessB);
 printf("Sub process has create/n");

 Sleep(5000);
 printf("After 5000ms,Sub Process has aroused/n");
 ResumeThread(piProcessB.hThread);
// CreateProcess(NULL,szPath1,NULL,NULL,TRUE,0,NULL,NULL,&si,&piProcessC);

 return 0;
}

由此可以得出结论,DETACHED_PROCESS使原来的控制台被覆盖,

你可能感兴趣的:(Security,null,Path,include,attributes)