Win32 API 日本語リファレンス
ホームSystem.Power › PPM_IDLE_ACCOUNTING_EX

PPM_IDLE_ACCOUNTING_EX

構造体
サイズx64: 440 バイト / x86: 440 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
StateCountDWORD4+0+0Stateフィールドに含まれるアイドル状態の数。
TotalTransitionsDWORD4+4+4すべてのアイドル遷移の総回数。
ResetCountDWORD4+8+8統計がリセットされた回数。
AbortCountDWORD4+12+12アイドル遷移が中断された回数。
StartTimeULONGLONG8+16+16統計収集を開始した時刻のタイムスタンプ。
StatePPM_IDLE_STATE_ACCOUNTING_EX416+24+24各アイドル状態ごとの拡張集計情報を格納する可変長配列。

各言語での定義

#include <windows.h>

// PPM_IDLE_STATE_BUCKET_EX  (x64 24 / x86 24 バイト)
typedef struct PPM_IDLE_STATE_BUCKET_EX {
    ULONGLONG TotalTimeUs;
    DWORD MinTimeUs;
    DWORD MaxTimeUs;
    DWORD Count;
} PPM_IDLE_STATE_BUCKET_EX;

// PPM_IDLE_STATE_ACCOUNTING_EX  (x64 416 / x86 416 バイト)
typedef struct PPM_IDLE_STATE_ACCOUNTING_EX {
    ULONGLONG TotalTime;
    DWORD IdleTransitions;
    DWORD FailedTransitions;
    DWORD InvalidBucketIndex;
    DWORD MinTimeUs;
    DWORD MaxTimeUs;
    DWORD CancelledTransitions;
    PPM_IDLE_STATE_BUCKET_EX IdleTimeBuckets[16];
} PPM_IDLE_STATE_ACCOUNTING_EX;

// PPM_IDLE_ACCOUNTING_EX  (x64 440 / x86 440 バイト)
typedef struct PPM_IDLE_ACCOUNTING_EX {
    DWORD StateCount;
    DWORD TotalTransitions;
    DWORD ResetCount;
    DWORD AbortCount;
    ULONGLONG StartTime;
    PPM_IDLE_STATE_ACCOUNTING_EX State[1];
} PPM_IDLE_ACCOUNTING_EX;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct PPM_IDLE_STATE_BUCKET_EX
{
    public ulong TotalTimeUs;
    public uint MinTimeUs;
    public uint MaxTimeUs;
    public uint Count;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct PPM_IDLE_STATE_ACCOUNTING_EX
{
    public ulong TotalTime;
    public uint IdleTransitions;
    public uint FailedTransitions;
    public uint InvalidBucketIndex;
    public uint MinTimeUs;
    public uint MaxTimeUs;
    public uint CancelledTransitions;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public PPM_IDLE_STATE_BUCKET_EX[] IdleTimeBuckets;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct PPM_IDLE_ACCOUNTING_EX
{
    public uint StateCount;
    public uint TotalTransitions;
    public uint ResetCount;
    public uint AbortCount;
    public ulong StartTime;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public PPM_IDLE_STATE_ACCOUNTING_EX[] State;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure PPM_IDLE_STATE_BUCKET_EX
    Public TotalTimeUs As ULong
    Public MinTimeUs As UInteger
    Public MaxTimeUs As UInteger
    Public Count As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure PPM_IDLE_STATE_ACCOUNTING_EX
    Public TotalTime As ULong
    Public IdleTransitions As UInteger
    Public FailedTransitions As UInteger
    Public InvalidBucketIndex As UInteger
    Public MinTimeUs As UInteger
    Public MaxTimeUs As UInteger
    Public CancelledTransitions As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=16)> Public IdleTimeBuckets() As PPM_IDLE_STATE_BUCKET_EX
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure PPM_IDLE_ACCOUNTING_EX
    Public StateCount As UInteger
    Public TotalTransitions As UInteger
    Public ResetCount As UInteger
    Public AbortCount As UInteger
    Public StartTime As ULong
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public State() As PPM_IDLE_STATE_ACCOUNTING_EX
End Structure
import ctypes
from ctypes import wintypes

class PPM_IDLE_STATE_BUCKET_EX(ctypes.Structure):
    _fields_ = [
        ("TotalTimeUs", ctypes.c_ulonglong),
        ("MinTimeUs", wintypes.DWORD),
        ("MaxTimeUs", wintypes.DWORD),
        ("Count", wintypes.DWORD),
    ]

class PPM_IDLE_STATE_ACCOUNTING_EX(ctypes.Structure):
    _fields_ = [
        ("TotalTime", ctypes.c_ulonglong),
        ("IdleTransitions", wintypes.DWORD),
        ("FailedTransitions", wintypes.DWORD),
        ("InvalidBucketIndex", wintypes.DWORD),
        ("MinTimeUs", wintypes.DWORD),
        ("MaxTimeUs", wintypes.DWORD),
        ("CancelledTransitions", wintypes.DWORD),
        ("IdleTimeBuckets", PPM_IDLE_STATE_BUCKET_EX * 16),
    ]

class PPM_IDLE_ACCOUNTING_EX(ctypes.Structure):
    _fields_ = [
        ("StateCount", wintypes.DWORD),
        ("TotalTransitions", wintypes.DWORD),
        ("ResetCount", wintypes.DWORD),
        ("AbortCount", wintypes.DWORD),
        ("StartTime", ctypes.c_ulonglong),
        ("State", PPM_IDLE_STATE_ACCOUNTING_EX * 1),
    ]
#[repr(C)]
pub struct PPM_IDLE_STATE_BUCKET_EX {
    pub TotalTimeUs: u64,
    pub MinTimeUs: u32,
    pub MaxTimeUs: u32,
    pub Count: u32,
}

#[repr(C)]
pub struct PPM_IDLE_STATE_ACCOUNTING_EX {
    pub TotalTime: u64,
    pub IdleTransitions: u32,
    pub FailedTransitions: u32,
    pub InvalidBucketIndex: u32,
    pub MinTimeUs: u32,
    pub MaxTimeUs: u32,
    pub CancelledTransitions: u32,
    pub IdleTimeBuckets: [PPM_IDLE_STATE_BUCKET_EX; 16],
}

#[repr(C)]
pub struct PPM_IDLE_ACCOUNTING_EX {
    pub StateCount: u32,
    pub TotalTransitions: u32,
    pub ResetCount: u32,
    pub AbortCount: u32,
    pub StartTime: u64,
    pub State: [PPM_IDLE_STATE_ACCOUNTING_EX; 1],
}
import "golang.org/x/sys/windows"

type PPM_IDLE_STATE_BUCKET_EX struct {
	TotalTimeUs uint64
	MinTimeUs uint32
	MaxTimeUs uint32
	Count uint32
}

type PPM_IDLE_STATE_ACCOUNTING_EX struct {
	TotalTime uint64
	IdleTransitions uint32
	FailedTransitions uint32
	InvalidBucketIndex uint32
	MinTimeUs uint32
	MaxTimeUs uint32
	CancelledTransitions uint32
	IdleTimeBuckets [16]PPM_IDLE_STATE_BUCKET_EX
}

type PPM_IDLE_ACCOUNTING_EX struct {
	StateCount uint32
	TotalTransitions uint32
	ResetCount uint32
	AbortCount uint32
	StartTime uint64
	State [1]PPM_IDLE_STATE_ACCOUNTING_EX
}
type
  PPM_IDLE_STATE_BUCKET_EX = record
    TotalTimeUs: UInt64;
    MinTimeUs: DWORD;
    MaxTimeUs: DWORD;
    Count: DWORD;
  end;

  PPM_IDLE_STATE_ACCOUNTING_EX = record
    TotalTime: UInt64;
    IdleTransitions: DWORD;
    FailedTransitions: DWORD;
    InvalidBucketIndex: DWORD;
    MinTimeUs: DWORD;
    MaxTimeUs: DWORD;
    CancelledTransitions: DWORD;
    IdleTimeBuckets: array[0..15] of PPM_IDLE_STATE_BUCKET_EX;
  end;

  PPM_IDLE_ACCOUNTING_EX = record
    StateCount: DWORD;
    TotalTransitions: DWORD;
    ResetCount: DWORD;
    AbortCount: DWORD;
    StartTime: UInt64;
    State: array[0..0] of PPM_IDLE_STATE_ACCOUNTING_EX;
  end;
const PPM_IDLE_STATE_BUCKET_EX = extern struct {
    TotalTimeUs: u64,
    MinTimeUs: u32,
    MaxTimeUs: u32,
    Count: u32,
};

const PPM_IDLE_STATE_ACCOUNTING_EX = extern struct {
    TotalTime: u64,
    IdleTransitions: u32,
    FailedTransitions: u32,
    InvalidBucketIndex: u32,
    MinTimeUs: u32,
    MaxTimeUs: u32,
    CancelledTransitions: u32,
    IdleTimeBuckets: [16]PPM_IDLE_STATE_BUCKET_EX,
};

const PPM_IDLE_ACCOUNTING_EX = extern struct {
    StateCount: u32,
    TotalTransitions: u32,
    ResetCount: u32,
    AbortCount: u32,
    StartTime: u64,
    State: [1]PPM_IDLE_STATE_ACCOUNTING_EX,
};
type
  PPM_IDLE_STATE_BUCKET_EX {.bycopy.} = object
    TotalTimeUs: uint64
    MinTimeUs: uint32
    MaxTimeUs: uint32
    Count: uint32

  PPM_IDLE_STATE_ACCOUNTING_EX {.bycopy.} = object
    TotalTime: uint64
    IdleTransitions: uint32
    FailedTransitions: uint32
    InvalidBucketIndex: uint32
    MinTimeUs: uint32
    MaxTimeUs: uint32
    CancelledTransitions: uint32
    IdleTimeBuckets: array[16, PPM_IDLE_STATE_BUCKET_EX]

  PPM_IDLE_ACCOUNTING_EX {.bycopy.} = object
    StateCount: uint32
    TotalTransitions: uint32
    ResetCount: uint32
    AbortCount: uint32
    StartTime: uint64
    State: array[1, PPM_IDLE_STATE_ACCOUNTING_EX]
struct PPM_IDLE_STATE_BUCKET_EX
{
    ulong TotalTimeUs;
    uint MinTimeUs;
    uint MaxTimeUs;
    uint Count;
}

struct PPM_IDLE_STATE_ACCOUNTING_EX
{
    ulong TotalTime;
    uint IdleTransitions;
    uint FailedTransitions;
    uint InvalidBucketIndex;
    uint MinTimeUs;
    uint MaxTimeUs;
    uint CancelledTransitions;
    PPM_IDLE_STATE_BUCKET_EX[16] IdleTimeBuckets;
}

struct PPM_IDLE_ACCOUNTING_EX
{
    uint StateCount;
    uint TotalTransitions;
    uint ResetCount;
    uint AbortCount;
    ulong StartTime;
    PPM_IDLE_STATE_ACCOUNTING_EX[1] State;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; PPM_IDLE_ACCOUNTING_EX サイズ: 440 バイト(x64)
dim st, 110    ; 4byte整数×110(構造体サイズ 440 / 4 切り上げ)
; StateCount : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; TotalTransitions : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; ResetCount : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; AbortCount : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; StartTime : ULONGLONG (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; State : PPM_IDLE_STATE_ACCOUNTING_EX (+24, 416byte)  varptr(st)+24 を基点に操作(416byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global PPM_IDLE_STATE_BUCKET_EX
    #field int64 TotalTimeUs
    #field int MinTimeUs
    #field int MaxTimeUs
    #field int Count
#endstruct

#defstruct global PPM_IDLE_STATE_ACCOUNTING_EX
    #field int64 TotalTime
    #field int IdleTransitions
    #field int FailedTransitions
    #field int InvalidBucketIndex
    #field int MinTimeUs
    #field int MaxTimeUs
    #field int CancelledTransitions
    #field PPM_IDLE_STATE_BUCKET_EX IdleTimeBuckets 16
#endstruct

#defstruct global PPM_IDLE_ACCOUNTING_EX
    #field int StateCount
    #field int TotalTransitions
    #field int ResetCount
    #field int AbortCount
    #field int64 StartTime
    #field PPM_IDLE_STATE_ACCOUNTING_EX State 1
#endstruct

stdim st, PPM_IDLE_ACCOUNTING_EX        ; NSTRUCT 変数を確保
st->StateCount = 100
mes "StateCount=" + st->StateCount