ホーム › Devices.Usb › USB_POWER_INFO
USB_POWER_INFO
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| SystemState | WDMUSB_POWER_STATE | 4 | +0 | +0 | 対象とするシステム電源状態を示すWDMUSB_POWER_STATE列挙値。 |
| HcDevicePowerState | WDMUSB_POWER_STATE | 4 | +4 | +4 | ホストコントローラのデバイス電源状態を示す。 |
| HcDeviceWake | WDMUSB_POWER_STATE | 4 | +8 | +8 | ホストコントローラがウェイク可能な最深電源状態を示す。 |
| HcSystemWake | WDMUSB_POWER_STATE | 4 | +12 | +12 | ホストコントローラがシステムをウェイクできる電源状態を示す。 |
| RhDevicePowerState | WDMUSB_POWER_STATE | 4 | +16 | +16 | ルートハブのデバイス電源状態を示す。 |
| RhDeviceWake | WDMUSB_POWER_STATE | 4 | +20 | +20 | ルートハブがウェイク可能な最深電源状態を示す。 |
| RhSystemWake | WDMUSB_POWER_STATE | 4 | +24 | +24 | ルートハブがシステムをウェイクできる電源状態を示す。 |
| LastSystemSleepState | WDMUSB_POWER_STATE | 4 | +28 | +28 | 直近のシステムスリープ状態を示す。 |
| CanWakeup | BOOLEAN | 1 | +32 | +32 | デバイスがシステムをウェイクできるか示す真偽値。 |
| IsPowered | BOOLEAN | 1 | +33 | +33 | デバイスが現在給電されているか示す真偽値。 |
各言語での定義
#include <windows.h>
// USB_POWER_INFO (x64 34 / x86 34 バイト)
#pragma pack(push, 1)
typedef struct USB_POWER_INFO {
WDMUSB_POWER_STATE SystemState;
WDMUSB_POWER_STATE HcDevicePowerState;
WDMUSB_POWER_STATE HcDeviceWake;
WDMUSB_POWER_STATE HcSystemWake;
WDMUSB_POWER_STATE RhDevicePowerState;
WDMUSB_POWER_STATE RhDeviceWake;
WDMUSB_POWER_STATE RhSystemWake;
WDMUSB_POWER_STATE LastSystemSleepState;
BOOLEAN CanWakeup;
BOOLEAN IsPowered;
} USB_POWER_INFO;
#pragma pack(pop)using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct USB_POWER_INFO
{
public int SystemState;
public int HcDevicePowerState;
public int HcDeviceWake;
public int HcSystemWake;
public int RhDevicePowerState;
public int RhDeviceWake;
public int RhSystemWake;
public int LastSystemSleepState;
[MarshalAs(UnmanagedType.U1)] public bool CanWakeup;
[MarshalAs(UnmanagedType.U1)] public bool IsPowered;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure USB_POWER_INFO
Public SystemState As Integer
Public HcDevicePowerState As Integer
Public HcDeviceWake As Integer
Public HcSystemWake As Integer
Public RhDevicePowerState As Integer
Public RhDeviceWake As Integer
Public RhSystemWake As Integer
Public LastSystemSleepState As Integer
<MarshalAs(UnmanagedType.U1)> Public CanWakeup As Boolean
<MarshalAs(UnmanagedType.U1)> Public IsPowered As Boolean
End Structureimport ctypes
from ctypes import wintypes
class USB_POWER_INFO(ctypes.Structure):
_pack_ = 1
_fields_ = [
("SystemState", ctypes.c_int),
("HcDevicePowerState", ctypes.c_int),
("HcDeviceWake", ctypes.c_int),
("HcSystemWake", ctypes.c_int),
("RhDevicePowerState", ctypes.c_int),
("RhDeviceWake", ctypes.c_int),
("RhSystemWake", ctypes.c_int),
("LastSystemSleepState", ctypes.c_int),
("CanWakeup", ctypes.c_byte),
("IsPowered", ctypes.c_byte),
]#[repr(C, packed(1))]
pub struct USB_POWER_INFO {
pub SystemState: i32,
pub HcDevicePowerState: i32,
pub HcDeviceWake: i32,
pub HcSystemWake: i32,
pub RhDevicePowerState: i32,
pub RhDeviceWake: i32,
pub RhSystemWake: i32,
pub LastSystemSleepState: i32,
pub CanWakeup: u8,
pub IsPowered: u8,
}import "golang.org/x/sys/windows"
type USB_POWER_INFO struct {
SystemState int32
HcDevicePowerState int32
HcDeviceWake int32
HcSystemWake int32
RhDevicePowerState int32
RhDeviceWake int32
RhSystemWake int32
LastSystemSleepState int32
CanWakeup byte
IsPowered byte
}type
USB_POWER_INFO = packed record
SystemState: Integer;
HcDevicePowerState: Integer;
HcDeviceWake: Integer;
HcSystemWake: Integer;
RhDevicePowerState: Integer;
RhDeviceWake: Integer;
RhSystemWake: Integer;
LastSystemSleepState: Integer;
CanWakeup: ByteBool;
IsPowered: ByteBool;
end;const USB_POWER_INFO = extern struct {
SystemState: i32,
HcDevicePowerState: i32,
HcDeviceWake: i32,
HcSystemWake: i32,
RhDevicePowerState: i32,
RhDeviceWake: i32,
RhSystemWake: i32,
LastSystemSleepState: i32,
CanWakeup: u8,
IsPowered: u8,
};type
USB_POWER_INFO {.packed.} = object
SystemState: int32
HcDevicePowerState: int32
HcDeviceWake: int32
HcSystemWake: int32
RhDevicePowerState: int32
RhDeviceWake: int32
RhSystemWake: int32
LastSystemSleepState: int32
CanWakeup: uint8
IsPowered: uint8align(1)
struct USB_POWER_INFO
{
int SystemState;
int HcDevicePowerState;
int HcDeviceWake;
int HcSystemWake;
int RhDevicePowerState;
int RhDeviceWake;
int RhSystemWake;
int LastSystemSleepState;
ubyte CanWakeup;
ubyte IsPowered;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; USB_POWER_INFO サイズ: 34 バイト(x64)
dim st, 9 ; 4byte整数×9(構造体サイズ 34 / 4 切り上げ)
; SystemState : WDMUSB_POWER_STATE (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; HcDevicePowerState : WDMUSB_POWER_STATE (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; HcDeviceWake : WDMUSB_POWER_STATE (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; HcSystemWake : WDMUSB_POWER_STATE (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; RhDevicePowerState : WDMUSB_POWER_STATE (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; RhDeviceWake : WDMUSB_POWER_STATE (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; RhSystemWake : WDMUSB_POWER_STATE (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; LastSystemSleepState : WDMUSB_POWER_STATE (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; CanWakeup : BOOLEAN (+32, 1byte) poke st,32,値 / 値 = peek(st,32)
; IsPowered : BOOLEAN (+33, 1byte) poke st,33,値 / 値 = peek(st,33)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global USB_POWER_INFO, pack=1
#field int SystemState
#field int HcDevicePowerState
#field int HcDeviceWake
#field int HcSystemWake
#field int RhDevicePowerState
#field int RhDeviceWake
#field int RhSystemWake
#field int LastSystemSleepState
#field bool1 CanWakeup
#field bool1 IsPowered
#endstruct
stdim st, USB_POWER_INFO ; NSTRUCT 変数を確保
st->SystemState = 100
mes "SystemState=" + st->SystemState