|
-
Apr 5th, 2000, 10:54 PM
#1
Thread Starter
New Member
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?
-
Apr 6th, 2000, 01:52 AM
#2
Hyperactive Member
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.
-
Apr 6th, 2000, 08:01 AM
#3
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...
-
Apr 6th, 2000, 06:30 PM
#4
New Member
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
-
Apr 6th, 2000, 07:23 PM
#5
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|