引用: http://www.cnblogs.com/liuweilinlin/archive/2012/08/20/2647168.html STARTUPINFO StartupInfo;//創(chuàng)建進(jìn)程所需的信息結(jié)構(gòu)變量
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; //說(shuō)明進(jìn)程將以隱藏的方式在后臺(tái)執(zhí)行 StartupInfo.cbReserved2=0; StartupInfo.lpReserved2=NULL; StartupInfo.hStdInput=stdin; StartupInfo.hStdOutput=stdout; StartupInfo.hStdError=stderr; PROCESS_INFORMATION piProcess; BOOL bRet; bRet = CreateProcess(modName,NULL,NULL,NULL,TRUE,CREATE_NO_WINDOW ,NULL,NULL,&StartupInfo,&piProcess); if(bRet) CloseHandle(piProcess.hThread); CloseHandle(piProcess.hProcess); 注意其中的StartupInfo.dwFlags=STARTF_USESHOWWINDOW;是必須的,要不然showwindow的參數(shù)將無(wú)效,詳細(xì)的MSDN上寫(xiě)得清楚 |
|