Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Application not fully closing

Status
Not open for further replies.

sacsac

Programmer
Dec 10, 2000
174
0
0
GB
I have code in my app which prevents a second instance of it loading, and this seems to works fine. I check at load time, and if there is an instance already running then I gracefully warn the user of the problem, and exit the second instance by using "END". That's all fine, except that occasionally I have users reporting that they are receiving the warning when they apparently do not have the app already running. However, by looking into what's running by doing a CONTROL-ALT-DELETE there is indeed an instance already loaded. Any ideas what might be keeping the app in the Windows Task list even when it is apparently successfully unloaded?
 
Yes.

The "End" statement does NOT terminate the running application process. All it does is end and unload the form and programm code.
If you start (not get) any application process from within programm code, it usually runs in the background. So if wish to terminate that application process, you need to use a line
Code:
Dim wd as word.Application
...
wd.Quit
or anything analogous depending on which app you are controlling.
This is not an issue if you can fetch a running instance via "GetObject(Word.Application")", because then you do not start a background instance but simply get a running foreground one.

Hope this helps.
;-)

Cheers,
MiS

[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
Also make sure you implicitly unload all forms in a DMI app, if applicable, and implicitly close any connections and objects which may have been left open:
Code:
'conDMI is an ADO connection object

If Not conDMI Is Nothing Then
    conDMI.Close
    Set conDMI = Nothing
End If

Set cmdCommand = Nothing

etc...

Cogito eggo sum – I think, therefore I am a waffle.
 
OOPS!
in a DMI app

Make that MDI.
"DMI" is the name of the app I copied my code from. Not too confusing...

Cogito eggo sum – I think, therefore I am a waffle.
 
I thought that the END statement stopped all code execution, closed all files, cleared variables, destroyed all objects and freed memory. So what else is left which hasn't been dealt with?
 
See MakeItSo's post:
The "End" statement does NOT terminate the running application process. All it does is end and unload the form and programm code.

Cogito eggo sum – I think, therefore I am a waffle.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top