Cat123
February 22nd, 2003, 01:36 PM
EDIT: Sorry , I can't delete this post. Problem solved. Frankly, I don't know how it got solved....I stuck in a system("child1.exe") to see if at least that would work. It did, I took it out and then the other worked. Sorry again.
Hi,
I'm not sure, is this possible? I include window.h and winbase.h (where createProcess is defined)
By console pgm, I mean I have as my main pgm
int main()
not WinMain()
I call the createProcess, and get no errors, but it is returning FALSE, indicating that the process wasn't created.
Anyway, I'd really like to create a process with a console pgm (I am just learning processes....)
Thanx,
Cat
edit:
I copied this right from MSDN and it says the process wasn't created. I must be missing a header............????
int main( VOID )
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
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).
"MyChildProcess", // Command line.
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
0, // No creation flags.
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." );
}
// Wait until child process exits.
WaitForSingleObject( pi.hProcess, INFINITE );
// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
return 0;
}
Hi,
I'm not sure, is this possible? I include window.h and winbase.h (where createProcess is defined)
By console pgm, I mean I have as my main pgm
int main()
not WinMain()
I call the createProcess, and get no errors, but it is returning FALSE, indicating that the process wasn't created.
Anyway, I'd really like to create a process with a console pgm (I am just learning processes....)
Thanx,
Cat
edit:
I copied this right from MSDN and it says the process wasn't created. I must be missing a header............????
int main( VOID )
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
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).
"MyChildProcess", // Command line.
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
0, // No creation flags.
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." );
}
// Wait until child process exits.
WaitForSingleObject( pi.hProcess, INFINITE );
// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
return 0;
}