CreateProcess参数传递细节

bool CreateProcessTask(const CString& strETLPath)
{

    STARTUPINFO sInfo;
    PROCESS_INFORMATION pInfo;
    ZeroMemory(&sInfo,sizeof(sInfo));
    sInfo.cb=sizeof(sInfo);
    sInfo.dwFlags=STARTF_USESHOWWINDOW;
    sInfo.wShowWindow=SW_HIDE;

    CString strToolExe = strETLPath;
    strToolExe += _T(" ");
    strToolExe += _T("\"");
    strToolExe += m_strPipeNameI;
    strToolExe += _T("\"");
    strToolExe += _T(" ");
    strToolExe += _T("\"");
    strToolExe += m_strPipeNameO;
    strToolExe += _T("\"");
    
    //创建一个进程
    BOOL bRet = ::CreateProcess(NULL,strToolExe.GetBuffer(),
        NULL,
        NULL,
        FALSE,
        CREATE_NEW_CONSOLE ,
        NULL,
        NULL,
        &sInfo,
        &pInfo);

  

if (bRet)

{
    // 等待程序结束
    WaitForSingleObject(pInfo.hProcess,INFINITE);
    CloseHandle(pInfo.hProcess);        
}
    
    return true;
}

posted @ 2014-05-21 14:08  忆民  阅读(371)  评论(0)    收藏  举报