zoukankan      html  css  js  c++  java
  • CreateProcess执行一个控制台程序,隐藏窗口

    STARTUPINFO   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);

  • 相关阅读:
    POJ 1185 状压DP
    POJ 1321
    hdu 1384 查分约束
    hdu 2196 树形dp
    hdu 4612 双联通缩点+树形dp
    poj 3469 最小割模板sap+gap+弧优化
    hdu 4858 容器的简单模拟
    hdu 4857 逆向拓扑排序+反向输出
    isap算法模板poj 1273gap+弧优化 最大流
    ISAP 算法的学习
  • 原文地址:https://www.cnblogs.com/lidabo/p/10979334.html
Copyright © 2011-2022 走看看