Catching POWER On event

G

Guest

Hi all,

I try to catch startup event after a sleep mode. After some search I find
RequestPowerNotifications which seems to be the good API to use for such a
think.

I found this code by Alex Feinman, however it don't work:
http://www.alexfeinman.com/download.asp?doc=PowerAwareApp.zip

I've code pretty the same thing without more succes, I can just catch events
"sometimes". One time on 20, my app catch everything, and other times nothing.

The code was designed for Pocket PC 2003, and I work with a Pocket 2005, did
something has changed with these events?

Did someone have an idea of what could be wrong in the code? I use the
vb.net version.

Regards
 
G

Guest

Thanks for this it seems useful, but it watchs the registery, this is ok for
battery level, but I want to catch power on event, so I need to know the
registry key where the actual state is saved ... and I don't.
So if you know where is this key, i'm interrested in

Regards
 
G

Guest

I found the solution in order this sample works but I still have a strange
problem.

I use the API RequestPowerNotifications to be warn about power notifications.
It works well with this call and give me Transition notifications:

RequestPowerNotifications(m_hQueue, PowerEventType.PBT_TRANSITION)
but if I use this:

RequestPowerNotifications(m_hQueue, PowerEventType.PBT_TRANSITION Or
PowerEventType.PBT_POWERSTATUSCHANGE)
I get no notification at all


I use this prototype
<DllImport("coredll")> _
Private Shared Function RequestPowerNotifications(ByVal _
hMsgQ As IntPtr, _
ByVal Flags As PowerEventType) _
As IntPtr
End Function

Is the mistake in the prototype or in a bad convention I use?

Regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top