CreateProcess执行一个控制台程序,隐藏窗口

TARTUPINFO   StartupInfo;//创建进程所需的信息结构变量   
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; 

BOOL   bRet;    
char *proname = (char *)malloc(256);
proname = "E:\\work\\project0\\spider\\bin\\Release\\spider1.exe";
bRet   =   CreateProcess(proname,NULL,NULL,NULL,TRUE,CREATE_NO_WINDOW ,NULL,NULL,&StartupInfo,&ProcessInfo);   
WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
CloseHandle(ProcessInfo.hProcess);
CloseHandle(ProcessInfo.hThread);

原文链接: https://www.cnblogs.com/King2019Blog/p/11296711.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

    CreateProcess执行一个控制台程序,隐藏窗口

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/300250

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月15日 下午9:15
下一篇 2023年2月15日 下午9:17

相关推荐