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!

About Intercepting Shutdown of Windows...

Status
Not open for further replies.

pikkiorock

Programmer
Nov 22, 2001
16
0
0
IT
Hi to everyone.... I'm thinkin' about this point for many days... but I can't find nothing :(

I wish to know : does exists an API call (or something like that) to intercept the system shutdown event ?

My objective is launch a little exe file just before system shutdown

Thanx a lot :) byeeee

 
Hi,

I don't know of an API that'll tell you, but surely a far simpler way is to intercept the Form_QueryUnload event for your application and when UnloadMode = vbAppWindows then you know that Windows is trying to shut down.

- Andy
_______________________________
"On a clear disk you can seek forever"
 
You can't intercept the shutdown message (Andy's idea is more like what you'd want to do). The Windows shutdown message is AFAIK the highest priority message in the system (even higher than the power failure alert!) because if there's a misbehaving program the OS must have the ability to shutdown. So this message is not made available to user-mode programs.

Chip H.
 
Would it help to create a group policy logoff .exe in the mmc snap-in that runs at logoff? Not perfect, but depending on how your computers are used(ie. never logged off unless being turned off), it might work.
 
Thanx to everyone bros :)
I decided to modify my code so it can run like a service all day repeating
file writings every 5 minutes... in this way it can do its work in 5 minutes
before shutdown... what do you think about ?
 
I need to do the same thing (run a exe on log off), i just created an application and subclassed it. when windows sent the WM_QUERYENDSESSION message to the my application i then inserted my extra code i wanted to run, and then continued to shutdown windows.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top