I have a Qt application that periodically performs some checks using a video camera (it takes and processes an image every second). I need Windows to be active without going into hibernation nor sleep mode as long as the application is running and to achieve it I have added the following code fragment in the main.cpp file of my application

Qt Code:
  1. // ... previous code omitted
  2. // From documentation, it should inform the o.s. that the app is in use preventing it to hibernate or sleep
  3. SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED | ES_AWAYMODE_REQUIRED);
  4.  
  5. // Execute the main application
  6. LoginDialog loginDialog(!appMode);
  7. int result = loginDialog.proceed() ? application.exec() : 0;
  8.  
  9. // Restore to the previous state when the app closes
  10. SetThreadExecutionState(ES_CONTINUOUS);
  11.  
  12. return result;
To copy to clipboard, switch view to plain text mode 

Unfortunately this approach is not giving the desired effects and after some time it hibernates and I don't understand why. Unfortunately I can't run the program with administrator privileges and this could be the cause but I'm not sure. I would like some help in solving my problem.