How to detect when the user press the power buton?

I need to close my app when the user powers down the pda. But i don't know how to capture the event. It works with any other button using :
HRESULT SecondEventHandler::onKeyDown(DWORD dwKey, KeyList& keylist)
{
return -1;
}
but it doesn't capture the power button.
any advice?
HRESULT SecondEventHandler::onKeyDown(DWORD dwKey, KeyList& keylist)
{
return -1;
}
but it doesn't capture the power button.
any advice?