Page 1 of 1

How to obtain return value of a called exe?

Posted: Tue Jun 30, 2015 2:03 am
by hua
Hi guys,
If exe A calls exe B, using winexec() or waitrun(), how to get the value returned by exe B?

TIA

Re: How to obtain return value of a called exe?

Posted: Tue Jun 30, 2015 3:23 am
by nageswaragunupudi
WaitRun() is expected to return the exitcode of executed exe.
But somehow I could not get reliable results.
You may try testing it.

Re: How to obtain return value of a called exe?

Posted: Tue Jun 30, 2015 4:09 am
by hua
Thanks for the reply Rao.

I didn't manage to get it too and when I check the documentation it says waitrun() returns hInstance.

So I just wrote a workaround by having exe B dumped the return value in a file for exe A to read. It serve the purpose but not as neat as having exe A reading directly exe B's return value.

Re: How to obtain return value of a called exe?

Posted: Tue Jun 30, 2015 4:19 am
by nageswaragunupudi
Returns hInstance when __FLAT__ is not defined.
FWH is compiled with __FLAT__ defined.
The function should return ExitCode

Code: Select all

         hb_retnl( dwExitCode );
 
Mr Antonio can explain better.
So I just wrote a workaround by having exe B dumped the return value in a file for exe A to read
This is the best thing to do.

Re: How to obtain return value of a called exe?

Posted: Tue Jun 30, 2015 9:02 am
by hmpaquito
To communicate two exes programs. Send parameters or returns information:

- You can use aRead() and aSave() functions.
- Or better FW_ValToExp() funcion with memowrit() and & operator with memoread().

Re: How to obtain return value of a called exe?

Posted: Wed Jul 01, 2015 2:14 am
by hua
Thanks for the input Paco

Re: How to obtain return value of a called exe?

Posted: Wed Jul 01, 2015 10:46 am
by antolin
You can try INI files too

Re: How to obtain return value of a called exe?

Posted: Thu Jul 02, 2015 2:06 am
by hua
Thanks for the input Antolin. I do use ini file quite a lot.

Speaking of ini file, I find it annoying that it doesn't leave a blank space in between sections. It makes it hard to read and edit manually