[python-win32] registering for power events

Tim Roberts timr at probo.com
Tue Dec 15 19:28:50 CET 2009


Ross Boylan wrote:
> I would like my application to get notice when the system sleeps,
> hibernates, or wakes up.
> http://msdn.microsoft.com/en-us/library/aa373196(VS.85).aspx
> points me to RegisterPowerSettingNotification, but I do not see this in
> the latest docs from ActiveState.  MSDN only seems to provide a C++
> interface; I don't see any COM interface.
>
> I think this is new in Vista.  Is there a way to do this from Python?
>   

It is new in Vista.  You can certainly call this through ctypes.  It's a
simple API.

Be sure to wrap the ctypes call in a try/except, in case you happen to
run on XP.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list