多种方式查看电脑是否支持Modern Standby

控制台查看

CMD输入powercfg /a

显示如下有S0,则支持Modern Standby

注册表查看

Win+R 输入regedit进入注册表,

查看HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\ModernSleep路径下有否有参数EnabledActions=7

C++代码查看

#include <windows.h>
#include <tchar.h>
#include <powrprof.h>
#include <iostream>
using namespace std;
#pragma comment(lib,"PowrProf.lib")
int main(int argc, _TCHAR* argv[])
{
    SYSTEM_POWER_CAPABILITIES spc = {};
    NTSTATUS status = CallNtPowerInformation(SystemPowerCapabilities, NULL, 0, &spc, sizeof(spc));
    if (0 == status)
    {
        if (spc.AoAc)//return boolean type
        {
            // modern standby
        }
    }
    return 0;
}

C#代码查看

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ThinkDPMAddin.Utils
{
    public class WindowsApiTools
    {

        public struct SYSTEM_POWER_CAPABILITIES
        {
            // Misc supported system features
            public bool PowerButtonPresent;
            public bool SleepButtonPresent;
            public bool LidPresent;
            public bool SystemS1;
            public bool SystemS2;
            public bool SystemS3;
            public bool SystemS4;           // hibernate
            public bool SystemS5;           // off
            public bool HiberFilePresent;
            public bool FullWake;
            public bool VideoDimPresent;
            public bool ApmPresent;
            public bool UpsPresent;
            // Processors
            public bool ThermalControl;
            public bool ProcessorThrottle;
            public byte ProcessorMinThrottle;
            public byte ProcessorMaxThrottle;
            public bool FastSystemS4;
            public bool Hiberboot;
            public bool WakeAlarmPresent;
            public bool AoAc;
            // Disk
            public bool DiskSpinDown;
            // HiberFile
            public byte HiberFileType;
            public bool AoAcConnectivitySupported;
            public byte[] spare3;
            // System Battery
            public bool SystemBatteriesPresent;
            public bool BatteriesAreShortTerm;
            public BATTERY_REPORTING_SCALE[] BatteryScale;
            // Wake
            public SYSTEM_POWER_STATE AcOnLineWake;
            public SYSTEM_POWER_STATE SoftLidWake;
            public SYSTEM_POWER_STATE RtcWake;
            public SYSTEM_POWER_STATE MinDeviceWakeState; // note this may change on driver load
            public SYSTEM_POWER_STATE DefaultLowLatencyWake;
        }
        public enum SYSTEM_POWER_STATE
        {
            PowerSystemUnspecified = 0,
            PowerSystemWorking = 1,
            PowerSystemSleeping1 = 2,
            PowerSystemSleeping2 = 3,
            PowerSystemSleeping3 = 4,
            PowerSystemHibernate = 5,
            PowerSystemShutdown = 6,
            PowerSystemMaximum = 7
        }
        public struct BATTERY_REPORTING_SCALE
        {
            UInt32 Granularity;
            UInt32 Capacity;
        }
        [System.Runtime.InteropServices.DllImport("powrprof.dll", SetLastError = true)]
        public static extern uint CallNtPowerInformation(
            int InformationLevel,
            IntPtr lpInputBuffer,
            int nInputBufferSize,
            out SYSTEM_POWER_CAPABILITIES spi,
            int nOutputBufferSize
        );
        public static readonly int SYSTEMPOWERCAPABILITIES = 4;


        public static bool GetIsSupportMSDB()
        {
            SYSTEM_POWER_CAPABILITIES spi;
            uint retval = CallNtPowerInformation(
                SYSTEMPOWERCAPABILITIES, IntPtr.Zero, 0, out spi,System.Runtime.InteropServices.Marshal.SizeOf(typeof(SYSTEM_POWER_CAPABILITIES))
            );
            if (0 == retval && spi.AoAc)
            {
                return true;// modern standby
            }
            return false;
        }
    }
}

关闭/开启机器的Modern Standby(前提是电脑支持,不然开了也没用)

close:创建*.reg后缀文件,复制下面文本放进去运行

Windows Registry Editor Version 5.00

[-HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\ModernSleep]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power]
"PlatformAoAcOverride"=dword:00000000
"CsEnabled"=dword:00000000

open:创建reg后缀文件,复制下面文本放进去运行

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power]
"CsEnabled"=-
"PlatformAoAcOverride"=-

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\ModernSleep]
"EnabledActions"=dword:00000007

  • 4
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值