0

GetPwrCapabilitiesを呼び出している64ビットのWin7Ultimateマシンがあります。ただし、スリープ状態4(休止状態)が使用できず、休止状態ファイルがないことがわかります。マシンを休止状態にすることができ、休止状態ファイルがあります。私は何か間違ったことをしていますか?サポートされている正確な睡眠状態を取得するために呼び出すことができるものは他にありますか

ありがとう

編集 powercfg-AVAILABLESTATESが正しい情報を提供するのは興味深いことです。誰かがそれが呼び出すAPIまたは不一致がある理由を知っていますか

コードの追加

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Xml.Serialization;
using System.IO;
using System.Diagnostics;

class Program
{
    [DllImport("PowrProf.dll")]
    public static extern bool GetPwrCapabilities(out SYSTEM_POWER_CAPABILITIES lpSystemPowerCapabilities);

    static void Main(string[] args)
    {
        SYSTEM_POWER_CAPABILITIES spc;
        bool well = GetPwrCapabilities(out spc);

        Stream stdOut = System.Console.OpenStandardOutput();
        XmlSerializer x = new XmlSerializer(typeof(SYSTEM_POWER_CAPABILITIES));
        x.Serialize(stdOut, spc);
    }
}

[Serializable]
public struct SYSTEM_POWER_CAPABILITIES
{
    public bool PowerButtonPresent;
    public bool SleepButtonPresent;
    public bool LidPresent;
    public bool SystemS1;
    public bool SystemS2;
    public bool SystemS3;
    public bool SystemS4;
    public bool SystemS5;
    public bool HiberFilePresent;
    public bool FullWake;
    public bool VideoDimPresent;
    public bool ApmPresent;
    public bool UpsPresent;
    public bool ThermalControl;
    public bool ProcessorThrottle;
    public byte ProcessorMinThrottle;
    public byte ProcessorMaxThrottle;
    public bool FastSystemS4;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
    public byte[] spare2;
    public bool DiskSpinDown;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
    public byte[] spare3;
    public bool SystemBatteriesPresent;
    public bool BatteriesAreShortTerm;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
    public BATTERY_REPORTING_SCALE[] BatteryScale;
    public SYSTEM_POWER_STATE AcOnLineWake;
    public SYSTEM_POWER_STATE SoftLidWake;
    public SYSTEM_POWER_STATE RtcWake;
    public SYSTEM_POWER_STATE MinDeviceWakeState;
    public SYSTEM_POWER_STATE DefaultLowLatencyWake;
}
public struct BATTERY_REPORTING_SCALE
{
    public UInt32 Granularity;
    public UInt32 Capacity;
}
public enum SYSTEM_POWER_STATE
{
    PowerSystemUnspecified = 0,
    PowerSystemWorking = 1,
    PowerSystemSleeping1 = 2,
    PowerSystemSleeping2 = 3,
    PowerSystemSleeping3 = 4,
    PowerSystemHibernate = 5,
    PowerSystemShutdown = 6,
    PowerSystemMaximum = 7
}
4

1 に答える 1

2

boolは4バイトとしてマーシャリングされます。これはWin32BOOLと一致します。ただし、Win32 BOOLEANは1バイトであるため、すべてのSYSTEM_POWER_CAPABILITIESブールメンバーに。でフラグを立てる必要があります[MarshalAs(UnmanagedType.I1)]

于 2012-01-18T14:37:14.210 に答える