Setting Message.LongParm in the application close event sets the exit code which can be seen with the ERRORLEVEL variable in a command window.
I am working on a program in C++ that executes a PowerBuilder app. The problem is that Message.LongParm is a long (signed 32bit number) and the Windows API function called by the C++ program GetExitCodeProcess returns a DWORD which is an unsigned 32bit number (ulong in PB).
If I have this line of code in my close event:
Message.LongParm = 1
My C++ program then logs this message:
The application ended with return code: -1073741819
Here is the line of C++ code that creates the message:
sprintf(szErrText, "The application ended with return code: %d", dwReturn);
If I call ExitProcess from the PB app the code comes through correctly because the argument is defined as ulong. ExitProcess ends the process so isn't appropriate in most cases.
I want my C++ program to work equally well running PB and C++ programs. Any ideas?