To start an external program from a C / C++ program, I used the following code.
GetStartupInfo( &start_info ); // You must fill in this structure
ret = CreateProcess( NULL, // specify the executable program
(LPSTR)buffer, // the command line arguments
NULL,
NULL,
FALSE,
NORMAL_PRIORITY_CLASS | CREATE_NO_WINDOW,
NULL,
NULL,
&start_info,
&process_info);
// Successfully created the process. Wait for it to finish.
WaitForSingleObject( process_info.hProcess, INFINITE );
// Get the exit code.
result = GetExitCodeProcess(process_info.hProcess, &exitCode);
// Close the handles.
CloseHandle( process_info.hProcess );
CloseHandle( process_info.hThread );
The code starts an external program and waits, until this program has finished before processing the next lines of code.
After using this code for a couple of years now, I found a shorter version today …
ret = system((char *)buffer);
I found only one limitation. It will print any of your fprint statements to the Domino console; using CREATE_NO_WINDOW with CreateProcess, you can suppress the output.