You need to subclass your application's main window and wathc for a WM_POWER message.

If you recieve that message and the wParam is PWR_SUSPENDREQUEST then return PWR_FAIL and don't pass the message on to the default window proc then the power suspend will not go ahead.

There are some good examples at Merrion Computing