• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 418
  • Last Modified:

How to get an exit code?

Can VB application call another VB application and check the exit code of the other VB application when it exit?
If yes, how?
0
cwchaw
Asked:
cwchaw
  • 6
  • 5
  • 2
  • +2
1 Solution
 
74wolfgangCommented:
have you ever used dde ?
0
 
cwchawAuthor Commented:
Not to use dde or anything, just normal calling function from VB application.
Basically, I need to know how to generate an exit code for the calling program to get the value, just like dos command.
0
 
swiltCommented:
You could try setting a registry value and reading it from the other program using GetSetting and SaveSetting
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
cwchawAuthor Commented:
Good suggestion swilt, but if I still need to use exit code.  Is there a way?
Because I can use C to code exit -1 or 0 to generate exit code.
0
 
DalinCommented:
cwchaw,
You can start another app (include another VB App) from a vb App using the shell command.
You can terminiate the other app when your VB app terminate.
I do not think you will be able to "Check the code " of the other app, if you are talking about what the other app does in it's exit routine.
Let me know if I can be further help.
Regards
Dalin
0
 
DalinCommented:
cwchaw,
You can use sendkeys to excute the exit routine if you meant to excute the other app's exit routine. or use other way like closeWindow API or terminateProcess...
Regards
Dalin
0
 
cwchawAuthor Commented:
Dalin, I do consider shell command before.  As I understand shell command will return an application ID when it is succesful.

What I need is to detect the other application either it is succesful or fail based on the logic.

Example:
If condition 1
   success
else
  fail
endif
0
 
DalinCommented:
cwahaw,
You are right about Shell: It will return the task ID if it is successful (in terms of start the other App), or it will return zero if it fails.

I am not clear about condition1 in your example. Is it something determined by how your other app (the one been shelled, say)'s excution?  DO you want to decide whether to exit the apps based on condition one?

Regards
Dalin


0
 
cwchawAuthor Commented:
Yes, application A will call application B. B will execute the logic to determine how to exit , either success or fail.  So application A will based on the result of exit code from B to execute some logic.
0
 
DalinCommented:
cwchaw,
There is a couple of possibilities right from the top of my head:

1. Put the condition result in App. B's caption, say the title of App B is "This is AppB --True" or This is AppB - False" to indicate the sucess or fail of your condition, and have App A Chack the title with API call..  The disadvantage is it would be static-- App A can check it in a giving time interval, it will not get the status instantly.

2. Perform a DDE between the two Apps, let App A automatically linked to the status. You can get instant return of status change.  Have you done dde before? It is actually quite simple.

I will see if I can find easier way...If I do, I will report back to you.  Meanwhile, if the above two is something you like to try, let me know if I can help.

Regards
Dalin
0
 
cwchawAuthor Commented:
Because application A and B is develop by different party and to make things easy and clear, I am not suppose to use DDE or API to pass value.  So Dalin, I would take suggestion from swilt, using registry to save and get value.

Thank you very much for your effort.
0
 
DalinCommented:
cwchaw,
So you should reject my answer. If swilt can help you work it out, you should ask him to lock the question.
Good luck in your project.
Dalin
0
 
cwchawAuthor Commented:
swilt,

Please lock your answer, so that I can give you points.

Thanks again Dalin.
0
 
sirigereCommented:
I got another solution.
You can have another activex exe providing an object. In that you have some events so that it can be raised whenever the application exits.
This object can be accessed by many other application just by creating an instance of the object.
to make it efficient in performance wise you can set the instancing property of the server as "Global multi use"
let me know your response.

0
 
sirigereCommented:
I got another solution.
You can have another activex exe providing an object. In that you have some events so that it can be raised whenever the application exits.
This object can be accessed by many other application just by creating an instance of the object.
to make it efficient in performance wise you can set the instancing property of the server as "Global multi use"
let me know your response.

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 6
  • 5
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now