Results 1 to 5 of 5

Thread: Application return value

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2000
    Posts
    3
    I got two application. Application A is a menu program which calls the application B by using shell command. Application B is a standard vb.exe file.

    My question is how can I return an integer value from application B to A when program B ends itself? Application B should return different integer values depending upon performed tasks.

    Here is an example in C or C++
    void main()
    {
    /* perform some tasks
    return 0;
    }

    0 is returned to the operating system or calling program.

    Is there a way to apply this functionality in visual basic?



  2. #2
    Hyperactive Member
    Join Date
    Sep 1999
    Location
    Cleveland, Ohio
    Posts
    263
    Two ways you could do it:

    1.) Use the FindWindow API:
    Code:
    Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    
    Dim AppBCapt As String
    AppBCapt = "Application B's Caption"
    If FindWindow("ThunderRTForm, AppBCapt) <> 0 Then
    Msgbox AppBCapt + " is currently open!", vbExclamation
    Else
    Msgbox AppBCapt + " is currently closed.", vbCritical
    End If
    2.) Have Application B save a value to the registry using SaveSetting and GetSetting. If this value equals something, Application B is running. If there is no variable, Application B is closed.
    Phobic

  3. #3
    Guest
    I don't have a good answer but I don't think that's what the guy/gal wants, he/she wants to be able to return a value to the other program, for example, in C++ you can have a whole funtion that can return something here's an example:

    void addthis(num1, num2)
    {
    int num1;
    int num2;
    int result;
    result = num1 + num2;
    return result; /*This is what the person wants to know how to do in VB*/
    }

    and that would return the value of result to the program that's calling the funtion, that's what he wants to do.. the registry thing, yea it might work, but it's still not as dynamic though.. I really don't know how to do it, but this should clarify what the person wants...

  4. #4
    New Member
    Join Date
    Mar 2000
    Posts
    14
    use API functions

    1. use ExitProcess in the child exe
    2. use ExitCodeProcess in the calling program to find out the return value


    hope this helps.


    FireBeast

  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2000
    Posts
    3

    Thanks everyone

    ExitProcess and ExitCodeProcess solved the problem.

    Thanks again.

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