Tech Support > Microsoft Windows > Development Resources > CreateProcess() command works only in debug build
CreateProcess() command works only in debug build
Posted by glchin@hotmail.com on March 27th, 2007


The following code produces a sorted file with a debug build on VC++
6.0. However, the release build doesn't produce anything. Any ideas?


_snprintf( buf, MAX_PATH, "C:\\WINDOWS\\system32\\sort.exe /r /rec %d /
o %s %s", KEY_SIZE, output, toBeSorted );
buf[MAX_PATH] = '\0';
szCmdline = _tcsdup( TEXT(buf) );

ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );

// Start the child process.
if( !CreateProcess( NULL, // No module name (use command line)
szCmdline, // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
DETACHED_PROCESS, // Console application isn't initialized
with a console
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure
&pi ) // Pointer to PROCESS_INFORMATION structure
)
{
printf( "CreateProcess failed (%d)\n", GetLastError() );
return -1;
}

rc = WaitForSingleObject(pi.hProcess, INFINITE);
assert( rc == WAIT_OBJECT_0 );

CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);


Similar Posts