I am developing an EXE (type: Windows Application) in VB.NET. This EXE is called by an external program. But unfortunately it is necessary to return a value to that external program. Is there a possibility to do so? If yes, how?
Printable View
I am developing an EXE (type: Windows Application) in VB.NET. This EXE is called by an external program. But unfortunately it is necessary to return a value to that external program. Is there a possibility to do so? If yes, how?
Although I have never used it before, the System.Environment class has an Exit method which has a parameter to set the exit code for the process. If the other application is developed in a .NET language as well, you can use the ExitCode property of the System.Diagnostics.Process class to read it. If the other application is not developed in a .NET language, you can use the GetExitCodeProcess API function.
Thanks.
It seems to be so easy; but it isn't.
This is my code (a very short version):
The calling application is no .NET written application. But it does use the GetExitCodeProcess API function and all I get (in a MsgBox) is 0. Any idea?Code:Sub Main()
Dim args() As String
Dim i As Integer
Dim blnOK As Boolean = True
args = Environment.GetCommandLineArgs
If args.Length > 1 Then
mudtArgs = New EingabeParameter()
For i = 1 To args.Length - 1
MsgBox("Args(" & i & ") = " & args(i))
Next
End If
Environment.Exit(42)
End Sub
I'don't think ExitCode Porperty would do this .It's job only to get the result of an exiting an extrenal app .Zero successful , non-zero results in error .Quote:
Originally posted by Frans C
Although I have never used it before, the System.Environment class has an Exit method which has a parameter to set the exit code for the process. If the other application is developed in a .NET language as well, you can use the ExitCode property of the System.Diagnostics.Process class to read it. If the other application is not developed in a .NET language, you can use the GetExitCodeProcess API function.
Like I said, I have never used it before.
If it doesn't work, I'm afraid I can't help you.