1. Roland Smith
  2. PowerBuilder
  3. Thursday, 18 January 2018 03:37 AM UTC

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?

Brad Mettee Accepted Answer Pending Moderation
  1. Thursday, 18 January 2018 06:25 AM UTC
  2. PowerBuilder
  3. # 1

I needed to do something similar, and ExitProcess was the only way I found to do it. 

In your APP close event, make it be the last thing executed (after closing up connections, windows, destroying global objects). 

Note: When running from the PB IDE, you may want to comment out the statement, otherwise it'll close the PB IDE since it's actually the running app.

 

Comment
  1. Michael Kramer
  2. Friday, 19 January 2018 09:15 AM UTC
Note, ExitProcess cannot be POSTed!



I tried and ExitProcess has no effect when POSTed either directly or POSTing a wrapper function call ExitProcess directly.



So make sure all application clean-up code has completed prior to ExitProcess.



HTH /Michael

  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.