Im trying to call an exe using vb6 which I can do already, that part works.
but when the exe finishes I want to get the return values and use them in the
code to tell the user the action passed/failed or whatever.
I started by calling with shell command, tried several ways to catch the
results?
so the code just has a button and text box. button calls the exe, it seems
to always return 0, but when it fails its supposed to return 1 - 7 based on
the error. must not be doing the right thing
button click starts the exe, when I close the exe file and return to vb code
I want to catch the exit codes, how?
thanks in advance
Google for "ShellExecute and Wait". There are a couple of zillion ways.
Here is the granddaddy version ...
http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dnarvb4/html/msdn_shelexec.asp
Another...
http://planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=1102&lngWId=-10
More...
http://vbcity.com/forums/topic.asp?tid=22303
...
What happens is that I just want to get the exit code when the called exe
terminates and either Im not doing this right or the app itself is not
returning the various exit codes
in my code,
GetExitCodeProcess proc.hProcess, RetVal2
RetVal2 is always -1 but then if I change it to
RetVal = GetExitCodeProcess (proc.hProcess, RetVal2)
and assume that proc.hProcess works fine, it starts and I can see the
process number in the task manager associated with my expected exe
application that Im starting up
then here RetVal is always = 0
In the various sample programs, they seem to all use similar if not
identical calls to kernel32 functions. So now Im left wondering if the
application doesnt actually return various exit codes, or Im not doing the
right thing to discover them. Contacting the person responsible for the app
itself, I get an out of office reply...
"Ralph" wrote:
> ....
>
> Another...
> http://www.vbaccelerator.com/home/vb/code/libraries/Shell_Projects/Shell_And_Wait_For_Completion/article.asp
>
>
>
>
>
>
http://support.microsoft.com/kb/129796/EN-US/
quote...
Getting the Exit Code from the Shelled Application
It was common for a DOS application to return an exit code indicating the
status of the completed application. While Windows provides other ways to
convey the same information, some applications only provide exit codes.
Passing the process handle to the GetExitCodeProcess() API allows you to
retrieve this information.
I made a new app, copied and pasted the example, inserted my app for notepad
and it works perfect
Using this, it also shows that the app in question returns code 0 all the time
thanks