GetExitCodeProcess

Heike

Well-known member
Joined
Jun 5, 2002
Messages
56
I am developing an EXE in VB.NET. This EXE is called by another program and that program waits until my EXE has finished (I think by using WaitForSingleObject but Im not sure). My problem now is that the calling application wants to receive a return code. It is reading the return code by GetExitCodeProcess. But how can I send the return code? I tried Environment.Exit(42) and Environment.ExitCode = 42 and ExitProcess(42) (API) but everytime I get a 0. Are there some more possibilities to send a return code?
 
Using Environment.Exit(42) worked for me. I created a test project and compiled to WinTest.exe.

I put the following in a text file and gave it a VBS extension (like test.vbs). Running it launches the WinTest.exe program and waits til it closes. The MsgBox does indeed show 42.
Code:
Dim shell 
Set shell = CreateObject("WScript.Shell")
MsgBox(shell.Run("wintest.exe", 1, true))

Maybe your other program isnt checking the return code, but maybe trying to receive a windows message?

-nerseus
 
Yes, my other application is checking the return code by using GetExitCodeProcess.

I wrote a simple program in VB 6 that creates a process (like I expect from the other application) and then waits and after my EXE finshed gets the return code. There everything works fine.

My first thought was that the other application is not able to read my return code but there is only called an API function and therefore I would think that it doesnt matter which language it uses.

???????
 
Back
Top