Okay, I haven't been programming in C++ for a while, only C#. In C# htis was easy, but in C++ I have some problems...
I have a command line tool ( the Oracle SQLLdr in this case ) that I'd like to start and wait for. Works like a charm. However, I need to know if the started program terminated sucessfully. The Oracle documentation says the program will return 0 on success, other values for errors. Fine I thought, that's easy.
However, I found no way to retrieve my started applications return value. Not with the structure I have, nor with the structures of CreateProcess or even the dreaded WinExec. WaitForSingleObject and all process starting functions only return their own success or failure.
/// Calls the SQLLDR process to load the file
if( ! CreateControlFile() ) return false;
strParameters.Format( _T("userid=%s/%s@%s control=%s.CTL data=%s bad=%s.BAD LOG=%s.LOG"),
memset(&ExecuteInfo, 0, sizeof(ExecuteInfo));
ExecuteInfo.cbSize = sizeof(ExecuteInfo);
ExecuteInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ExecuteInfo.hwnd = 0;
ExecuteInfo.lpVerb = _T("open");
ExecuteInfo.lpFile = _T("SQLLDR");
ExecuteInfo.lpParameters = strParameters;
ExecuteInfo.lpDirectory = 0;
ExecuteInfo.nShow = SW_SHOW;
ExecuteInfo.hInstApp = 0;
if( ! ShellExecuteEx( &ExecuteInfo ) )
Error( _T( "Unable to start sql loader" ) );
WaitForSingleObject( ExecuteInfo.hProcess, INFINITE );
How do I get the return value of my started app once it terminated ?
Help me Obi-Wan CBoard, you are my only help...
( I'm pretty sure the answer will be simple, so here's my next post in advance: "DOH ! Thank you, I will take a course in googling and reading comprehension as soon as possible " )
I can use _tsystem( ... ) for this, but it's not really what I want to do...