CreateProcess執行一個控制檯程序,隱藏窗口

STARTUPINFO   StartupInfo;//建立進程所需的信息結構變量   ide

PROCESS_INFORMATION   ProcessInfo;     進程

GetStartupInfo(&StartupInfo);    
StartupInfo.lpReserved=NULL;    
StartupInfo.lpDesktop=NULL;    
StartupInfo.lpTitle=NULL;    
StartupInfo.dwX=0;    
StartupInfo.dwY=0;    
StartupInfo.dwXSize=0;    
StartupInfo.dwYSize=0;    
StartupInfo.dwXCountChars=500;    
StartupInfo.dwYCountChars=500;    
StartupInfo.dwFlags=STARTF_USESHOWWINDOW;    
StartupInfo.wShowWindow=SW_HIDE;    
//說明進程將以隱藏的方式在後臺執行    
StartupInfo.cbReserved2=0;    
StartupInfo.lpReserved2=NULL;    
StartupInfo.hStdInput=stdin;    
StartupInfo.hStdOutput=stdout;    
StartupInfo.hStdError=stderr;    it

BOOL   bRet;    後臺

char *proname = (char *)malloc(256);變量

proname = "E:\\work\\project0\\spider\\bin\\Release\\spider1.exe";top

bRet   =   CreateProcess(proname ,NULL,NULL,NULL,TRUE,CREATE_NO_WINDOW ,NULL,NULL,&StartupInfo,&ProcessInfo);   di

WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
CloseHandle(ProcessInfo.hProcess);
CloseHandle(ProcessInfo.hThread);tar

相關文章
相關標籤/搜索