Results 1 to 5 of 5

Thread: return value of EXE

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2002
    Posts
    79

    return value of EXE

    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?

  2. #2
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    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.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2002
    Posts
    79
    Thanks.
    It seems to be so easy; but it isn't.
    This is my code (a very short version):

    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
    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?

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    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.
    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 .

  5. #5
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    Like I said, I have never used it before.
    If it doesn't work, I'm afraid I can't help you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width