Click to See Complete Forum and Search --> : having your program run at shutdown
OmegaZero
Feb 19th, 2001, 11:43 AM
I have a program that I need to run at shutdown (after you click shutdown or restart from the menu). Does anybody know the code to do this and when I would have to load the program up in the first place (run the program at Startup and then it know when the computer is shutting down. Also I guess I need to know how to stop the computer from fully shutting down until my program is done and one it is done, how to let the computer continue shutting down! :) Phew! :)
thanks for everything!
YoungBuck
Feb 19th, 2001, 02:20 PM
If your app has a form in it you can use the following to run some code or cancel the windows shutdown....
Option Explicit
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
' This unload mode is only passed to QueryUnload event when windows is _
trying to shut down and your app is running
If UnloadMode = vbAppWindows Then
Dim iResponse As Integer
' run your code here
iResponse = MsgBox("Continue shutting down Windows?", vbYesNo)
If iResponse = vbNo Then
' if user decides not to shut down windows, then cancel the unload of this _
form thus cancelling Windows from shutting down
Cancel = True
End If
End If
End Sub
Note: To test this code you will have to compile the project into an .exe file and have it running when you choose to shutdown windows. Hope this helps!
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.