If the user requests the PC to sleep or hibernate, you just cannot stop it, which I guess is what you're saying because that works for me just fine when the user doesn't request the low power action.
Hibernation is not enabled by default in windows 7, but I guess you could disable hibernation by messing with power plans if your app is running elevated.