zoukankan      html  css  js  c++  java
  • 更改当前电源策略(使用SetActivePwrScheme API函数),自定义电源按钮动作(设置GLOBAL_POWER_POLICY)

    [cpp] view plain copy
     
    1. #include <windows.h>  
    2. #include <Powrprof.h>  
    3.   
    4. #pragma comment(lib, "Powrprof.lib")  
    5.   
    6. int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPreInstance, LPSTR lpCmdLine, int nShowCmd)  
    7. {  
    8.     UINT uiID = 0;  
    9.     POWER_POLICY PwrPolicy;  
    10.   
    11.     GetActivePwrScheme(&uiID);  
    12.     ReadPwrScheme(uiID, &PwrPolicy);  
    13.   
    14.     PwrPolicy.user.VideoTimeoutAc = 0;  
    15.     PwrPolicy.user.VideoTimeoutDc = 0;  
    16.   
    17.     WritePwrScheme(&uiID, NULL, NULL, &PwrPolicy);  
    18.     SetActivePwrScheme(uiID, NULL, &PwrPolicy);  
    19.   
    20.     return 1;  
    21. }  
    http://blog.csdn.net/zwfgdlc/article/details/5696711
     
     
     
    [cpp] view plain copy
     
    1. #include "stdafx.h"  
    2. #include <windows.h>  
    3. #include <Powrprof.h>  
    4.   
    5. #pragma comment(lib, "Powrprof.lib")  
    6.    
    7. int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPreInstance, LPTSTR lpCmdLine, int nShowCmd)  
    8. {  
    9.     UINT uiID = 0;  
    10.     GLOBAL_POWER_POLICY GlobalPowerPolicy;    
    11.       
    12.     GetActivePwrScheme(&uiID);  
    13.     ReadGlobalPwrPolicy(&GlobalPowerPolicy);  
    14.   
    15.     /* 
    16.     #define POWER_USER_NOTIFY_BUTTON        0x00000008 //问我要做什么 
    17.     #define POWER_USER_NOTIFY_SHUTDOWN      0x00000010 //关机  
    18.     #define POWER_FORCE_TRIGGER_RESET       0x80000000 //什么也不做 
    19.     */  
    20.     GlobalPowerPolicy.user.PowerButtonAc.EventCode = POWER_USER_NOTIFY_BUTTON;  
    21.     GlobalPowerPolicy.user.PowerButtonDc.EventCode = POWER_USER_NOTIFY_BUTTON;  
    22.   
    23.     WriteGlobalPwrPolicy(&GlobalPowerPolicy);  
    24.     SetActivePwrScheme(uiID, &GlobalPowerPolicy, NULL);  
    25.       
    26.     return 1;  
    27. }  
    http://blog.csdn.net/zwfgdlc/article/details/6416347
     
  • 相关阅读:
    主流的Nosql数据库的对比
    CCF考试真题题解
    排序
    2017-10-03-afternoon
    POJ——T 2728 Desert King
    51Nod——T 1686 第K大区间
    POJ——T 2976 Dropping tests
    2017-10-02-afternoon
    入参是小数的String,返回小数乘以100的String
    银联支付踩过的坑
  • 原文地址:https://www.cnblogs.com/findumars/p/6344962.html
Copyright © 2011-2022 走看看