[python-win32] Re: Catching Windows Shutdown events.
Roger Upole
rwupole at msn.com
Fri Apr 21 05:25:36 CEST 2006
Don Bright wrote:
> Hello,
>
> I need to do something when windows shuts down, as when someone presses the
> power button.
>
> I believe this is a window message, WM_QUERYENDSESSION or WM_ENDSESSION.
>
> I can't find any way to trap this in python.
>
> atexit() does not work.
>
> using the signal module to trap SIGBREAK or SIGTERM does not work either.
>
> Any help? Thanks.
You might be able to use win32api.SetConsoleCtrlHandler and catch the
CTRL_SHUTDOWN_EVENT that's sent to the console.
Roger
More information about the Python-win32
mailing list