- #include <windows.h>
- #include <Powrprof.h>
- #pragma comment(lib, "Powrprof.lib")
- int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPreInstance, LPSTR lpCmdLine, int nShowCmd)
- {
- UINT uiID = 0;
- POWER_POLICY PwrPolicy;
- GetActivePwrScheme(&uiID);
- ReadPwrScheme(uiID, &PwrPolicy);
- PwrPolicy.user.VideoTimeoutAc = 0;
- PwrPolicy.user.VideoTimeoutDc = 0;
- WritePwrScheme(&uiID, NULL, NULL, &PwrPolicy);
- SetActivePwrScheme(uiID, NULL, &PwrPolicy);
- return 1;
- }
http://blog.csdn.net/zwfgdlc/article/details/5696711
- #include "stdafx.h"
- #include <windows.h>
- #include <Powrprof.h>
- #pragma comment(lib, "Powrprof.lib")
- int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPreInstance, LPTSTR lpCmdLine, int nShowCmd)
- {
- UINT uiID = 0;
- GLOBAL_POWER_POLICY GlobalPowerPolicy;
- GetActivePwrScheme(&uiID);
- ReadGlobalPwrPolicy(&GlobalPowerPolicy);
- /*
- #define POWER_USER_NOTIFY_BUTTON 0x00000008 //问我要做什么
- #define POWER_USER_NOTIFY_SHUTDOWN 0x00000010 //关机
- #define POWER_FORCE_TRIGGER_RESET 0x80000000 //什么也不做
- */
- GlobalPowerPolicy.user.PowerButtonAc.EventCode = POWER_USER_NOTIFY_BUTTON;
- GlobalPowerPolicy.user.PowerButtonDc.EventCode = POWER_USER_NOTIFY_BUTTON;
- WriteGlobalPwrPolicy(&GlobalPowerPolicy);
- SetActivePwrScheme(uiID, &GlobalPowerPolicy, NULL);
- return 1;
- }
http://blog.csdn.net/zwfgdlc/article/details/6416347