Help needed calling a VB6 exe from within another and closing the calling exe.

15 pts.
Tags:
Microsoft Windows XP
ShellExecute
Visual Basic
Visual Basic 6
I have 3 compiled vb6 projects. They all interact with each other but are kept as separate exe's to ease upgrading etc. I can use shell or shellexecute to run the other exe files from within an exe but I cannot fully close the calling exe file. I can get it to dissapear from everywhere except the Task Manager. Using accepted solution found here it tells me its been killed, but it hasn't really. What I am trying to achieve is as follows: 1.exe calls 2.exe, as 2,exe loads it closes 1.exe. 2.exe calls 3.exe which as it loads closes 2.exe 3.exe calls 1,exe and again, as 1,exe loads it closes 3.exe etc etc. The user could quite well keep flitting about between the exe files and I can't imaging what it would do the pc memory if they don't unload as they go. Any pointers much appreciated

Answer Wiki

Thanks. We'll let you know when a new response is added.

Is there any reason why the calling program can’t unload itself after calling the other program?

If that’s not an option, have a look at an example program you can download here (with source code).

The only difference with your code, is that this program doesn’t get the window handle by caption, but it creates a loop to close all windows from a particular process id. If you want to try this method, you would need to find the process id of the program you want to close.

Discuss This Question: 4  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Timjohn
    Absolutely no reason why the calling program cant close itself. I tried 'Unload me' after the shell but that closed all instances or rather closed the running exe and didn't open the shelled program. Meanwjhile, I'll look at the sample program you pointed to, thanks for your help.
    15 pointsBadges:
    report
  • carlosdl
    I wrote a simple program to test it. It worked fine for me, in both cases, using 'Unload Me', and 'End'. Here are the code snippets:
    sProgram = Trim$(txtProgram)
    glPid = Shell(sProgram , vbNormalFocus)
    Unload Me
    sProgram = Trim$(txtProgram)
    glPid = Shell(sProgram , vbNormalFocus)
    End
    70,220 pointsBadges:
    report
  • Acrotzer1
    How did you get the executions from one exe to the other?
    10 pointsBadges:
    report
  • carlosdl
    This is the line that executes the other exe: glPid = Shell(sProgram , vbNormalFocus)
    70,220 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following