Detect when my application is killed

akaris
04-08-2004, 01:27 PM
Hi!

I'm trying to detect when my application is killed (End task or process in the Windows Task Manager). If I could detect it, I could end the app normally instead of ""crashing"". Does someone know if it is possible? I've searched pretty much to find something...but found nothing!

Thanks,

- Mike Nadeau

Glade
04-08-2004, 02:21 PM
Use the QueryUnload event in your main form. It will tell you the UnloadMode. From the help:


vbFormControlMenu 0 The user chose the Close command from the Control menu on the form.
vbFormCode 1 The Unload statement is invoked from code.
vbAppWindows 2 The current Microsoft Windows operating environment session is ending.
vbAppTaskManager 3 The Microsoft Windows Task Manager is closing the application.
vbFormMDIForm 4 An MDI child form is closing because the MDI form is closing.
vbFormOwner 5 A form is closing because its owner is closing.

Jigo
04-08-2004, 02:30 PM
Try:


If App.PrevInstance = True Then 'application is running
'do something
Else 'application is not running
'do other
End If

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum