Solved

How to get an exit code?

Posted on 1998-07-20
15
407 Views
Last Modified: 2012-05-04
Can VB application call another VB application and check the exit code of the other VB application when it exit?
If yes, how?
0
Comment
Question by:cwchaw
  • 6
  • 5
  • 2
  • +2
15 Comments
 

Expert Comment

by:74wolfgang
ID: 1466269
have you ever used dde ?
0
 

Author Comment

by:cwchaw
ID: 1466270
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
 
LVL 2

Expert Comment

by:swilt
ID: 1466271
You could try setting a registry value and reading it from the other program using GetSetting and SaveSetting
0
 

Author Comment

by:cwchaw
ID: 1466272
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
 
LVL 9

Accepted Solution

by:
Dalin earned 200 total points
ID: 1466273
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
 
LVL 9

Expert Comment

by:Dalin
ID: 1466274
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
 

Author Comment

by:cwchaw
ID: 1466275
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 9

Expert Comment

by:Dalin
ID: 1466276
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
 

Author Comment

by:cwchaw
ID: 1466277
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
 
LVL 9

Expert Comment

by:Dalin
ID: 1466278
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
 

Author Comment

by:cwchaw
ID: 1466279
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
 
LVL 9

Expert Comment

by:Dalin
ID: 1466280
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
 

Author Comment

by:cwchaw
ID: 1466281
swilt,

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

Thanks again Dalin.
0
 
LVL 1

Expert Comment

by:sirigere
ID: 1466282
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
 
LVL 1

Expert Comment

by:sirigere
ID: 1466283
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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now