1. #include <windows.h>
  2. #include <Powrprof.h>
  3. #pragma comment(lib, "Powrprof.lib")
  4. int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPreInstance, LPSTR lpCmdLine, int nShowCmd)
  5. {
  6. UINT uiID = 0;
  7. POWER_POLICY PwrPolicy;
  8. GetActivePwrScheme(&uiID);
  9. ReadPwrScheme(uiID, &PwrPolicy);
  10. PwrPolicy.user.VideoTimeoutAc = 0;
  11. PwrPolicy.user.VideoTimeoutDc = 0;
  12. WritePwrScheme(&uiID, NULL, NULL, &PwrPolicy);
  13. SetActivePwrScheme(uiID, NULL, &PwrPolicy);
  14. return 1;
  15. }
http://blog.csdn.net/zwfgdlc/article/details/5696711
 
 
 
  1. #include "stdafx.h"
  2. #include <windows.h>
  3. #include <Powrprof.h>
  4. #pragma comment(lib, "Powrprof.lib")
  5. int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPreInstance, LPTSTR lpCmdLine, int nShowCmd)
  6. {
  7. UINT uiID = 0;
  8. GLOBAL_POWER_POLICY GlobalPowerPolicy;
  9. GetActivePwrScheme(&uiID);
  10. ReadGlobalPwrPolicy(&GlobalPowerPolicy);
  11. /*
  12. #define POWER_USER_NOTIFY_BUTTON        0x00000008 //问我要做什么
  13. #define POWER_USER_NOTIFY_SHUTDOWN      0x00000010 //关机
  14. #define POWER_FORCE_TRIGGER_RESET       0x80000000 //什么也不做
  15. */
  16. GlobalPowerPolicy.user.PowerButtonAc.EventCode = POWER_USER_NOTIFY_BUTTON;
  17. GlobalPowerPolicy.user.PowerButtonDc.EventCode = POWER_USER_NOTIFY_BUTTON;
  18. WriteGlobalPwrPolicy(&GlobalPowerPolicy);
  19. SetActivePwrScheme(uiID, &GlobalPowerPolicy, NULL);
  20. return 1;
  21. }
http://blog.csdn.net/zwfgdlc/article/details/6416347
 
05-27 10:16