PRB: ?????? ??? ????? ??? ?????? ????? ??????? CreateProcess

?????? ????????? ?????? ?????????
???? ???????: 315939 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

?? ??? ??????

???????

??? ????? ????? ????? ???????? ?????? CreateProcess ????????? ?? ???? ?????? ?????? ?????, ?? ??????? ??? ????? ?? ????? ???? ??????.

?????

?? ???? ??? ?????? ??? ?????? ??????? ?????? ?? ??? ????? ????? ?????? ????? ?????? ????? ????? STD ???? ??????? ???????. ?? ??? ?????????? ???? ???? ????? ????? ????? ??????? ??????? ? ???????? ???? ??? ?? ?????? ???? ???? ?? ??? ?????? ??????? ???? ??????? ??????. ????? ???? ????? ???? ??? ??????? ??????? ? ????? ???? ???? ??????? ??? ?? ????? ????? ??????? ??? ???? ????? ??? ????? ????? ????? ?????. ??? ????? ???? ????????? ??????? ??????? ?? ??????? ????? ??????? CreateProcess ??? ????? ??????.

????

??????? ?????? ??? ??? ??????? ?????? ??? ????? ??? ?? ???? ???. ???? ??? ??? ??? ?? ????? ????? ?????. ???? ??????? ????? ???? ???? ????? ?????? ?? noninheritable ?????? ????? ???? ?????? ??? NULL. ?? ?? ?????? ????? ?? ????? ??????? ???? ????? ??????? ??? ?? ??????? ??????? ???????? ??????? ???? SetHandleInformation ??? ?? ????? ?? ????? ????????? ???????? ??????:
CRITICAL_SECTION    cs;
HANDLE              hReadIn, hWriteIn;
HANDLE              hReadOut, hWriteOut;
HANDLE              hReadErr, hWriteErr;

InitializeCriticalSection(&cs);

EnterCriticalSection(&cs);

if ( !CreatePipe(&hReadIn, &hWriteIn, NULL, 0) )
{
    // an error occurred
}

if ( !CreatePipe(&hReadOut, &hWriteOut, NULL, 0) )
{
    // an error occurred
}

if ( !CreatePipe(&hReadErr, &hWriteErr, NULL, 0) )
{
    // an error occurred
}

if ( !SetHandleInformation(hReadIn, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT) )
{
    // an error occurred
}

if ( !SetHandleInformation(hWriteOut, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT) )
{
    // an error occurred
}

if ( !SetHandleInformation(hWriteErr, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT) )
{
    // an error occurred
}

STARTUP_INFO        si;
PROCESS_INFORMATION pi;

si.cb = sizeof(si);
si.dwFlags = STARTF_USESTDHANDLES;
si.hStdInput = hReadIn;
si.hStdOutput = hWriteOut;
si.hStdError = hWriteErr;

if ( !CreateProcess( "child.exe",
                     NULL,
                     NULL, NULL,
                     TRUE,
                     NORMAL_PRIORITY_CLASS,
                     lpEnvironment,
                     &si, &pi) )
{
    // an error occurred
}

CloseHandle(hReadIn);
CloseHandle(hWriteOut);
CloseHandle(hWriteErr);

LeaveCriticalSection(&cs);
				
?????? ?? ???? ???? ?????? ??? ????????. ????? ??????? ?????? ?? ????????? ???????? ??????? messy ???? ???? ????? ???? ?????. ???? ?? ??? ??? ??? ??????? ?? ????? ????? ????? ??????? ?????? ??????. ??? ????? ?? ???? ????? ??? ???? ????? downside ????? ??. ???? ??????? ??? ??? ??????? ??? ???? ????? ???? ????? ????? ???? ???? ??? ????? ????? ??????. ??? ????? ????? ????? ???????, ??????? ???????? ??? ?? ??? ???? ??? ???? ??.

???????? ??? ??????? ??????? ???????? ???? ?? ????? ??? ???????? ?????? ???????? ??? Windows ?????? ????? ????? ???. ?? ???? ???????? ????? ????? ?? ??????? ???????? ??? ???? ?? ???? ????? ??? ??? ??????. ??? ???? ??? ???? ????? bInheritHandles ?? ??????? CreateProcess ?? ????? ??????? FALSE. ??? ?? ???? ??? ????? ????? ????? ??????? ??? Windows ????? ????? STD ???? ????? ??? ??? ????? bInheritHandles ??? FALSE.

??????? ?????

HANDLE              hReadIn, hWriteIn;
HANDLE              hReadOut, hWriteOut;
HANDLE              hReadErr, hWriteErr;

if ( !CreatePipe(&hReadIn, &hWriteIn, NULL, 0) )
{
    // an error occurred
}

if ( !CreatePipe(&hReadOut, &hWriteOut, NULL, 0) )
{
    // an error occurred
}

if ( !CreatePipe(&hReadErr, &hWriteErr, NULL, 0) )
{
    // an error occurred
}

STARTUP_INFO        si;
PROCESS_INFORMATION pi;

si.cb = sizeof(si);
si.dwFlags = STARTF_USESTDHANDLES;
si.hStdInput = hReadIn;
si.hStdOutput = hWriteOut;
si.hStdError = hWriteErr;

if ( !CreateProcess( "Intermediate.exe",
                     NULL,
                     NULL, NULL,
                     TRUE,
                     NORMAL_PRIORITY_CLASS,
                     lpEnvironment,
                     &si, &pi) )
{
    // an error occurred
}

CloseHandle(hReadIn);
CloseHandle(hWriteOut);
CloseHandle(hWriteErr);
				

????? ????????

STARTUP_INFO        si;
PROCESS_INFORMATION pi;

si.cb = sizeof(si);

if ( !CreateProcess( "child.exe",
                     NULL,
                     NULL, NULL,
                     FALSE,
                     NORMAL_PRIORITY_CLASS,
                     lpEnvironment,
                     &si, &pi) )
{
    // an error occurred
}
				

???????

???? ???????: 315939 - ????? ??? ??????: 30/????/1427 - ??????: 4.1
????? ???
  • Microsoft Win32 ????? ????? ???????, ????? ?????? ??:
    • the operating system: Microsoft Windows XP
    • the operating system: Microsoft Windows 2000
    • Microsoft Windows NT 4.0
????? ??????: 
kbmt kbapi kbkernbase kbprb kbthread KB315939 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????315939

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com