ホーム › System.Power › BATTERY_USB_CHARGER_STATUS
BATTERY_USB_CHARGER_STATUS
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| Type | BATTERY_CHARGING_SOURCE_TYPE | 4 | +0 | +0 | 充電ソースの種別(BATTERY_CHARGING_SOURCE_TYPE: USB)である。 |
| Reserved | DWORD | 4 | +4 | +4 | 予約フィールドである。0となる。 |
| Flags | DWORD | 4 | +8 | +8 | USB充電器の状態を示すフラグである。 |
| MaxCurrent | DWORD | 4 | +12 | +12 | USB充電器が供給可能な最大電流(mA)である。 |
| Voltage | DWORD | 4 | +16 | +16 | USB充電器の電圧(mV)である。 |
| PortType | USB_CHARGER_PORT | 4 | +20 | +20 | USBポートの種別(USB_CHARGER_PORT)である。 |
| PortId | ULONGLONG | 8 | +24 | +24 | USBポートを識別するIDである。 |
| PowerSourceInformation | void* | 8/4 | +32 | +32 | 電源ソースに関する追加情報へのポインタである。NULL可。 |
| OemCharger | GUID | 16 | +40 | +36 | OEM固有の充電器を識別するGUIDである。 |
各言語での定義
#include <windows.h>
// BATTERY_USB_CHARGER_STATUS (x64 56 / x86 56 バイト)
typedef struct BATTERY_USB_CHARGER_STATUS {
BATTERY_CHARGING_SOURCE_TYPE Type;
DWORD Reserved;
DWORD Flags;
DWORD MaxCurrent;
DWORD Voltage;
USB_CHARGER_PORT PortType;
ULONGLONG PortId;
void* PowerSourceInformation;
GUID OemCharger;
} BATTERY_USB_CHARGER_STATUS;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct BATTERY_USB_CHARGER_STATUS
{
public int Type;
public uint Reserved;
public uint Flags;
public uint MaxCurrent;
public uint Voltage;
public int PortType;
public ulong PortId;
public IntPtr PowerSourceInformation;
public Guid OemCharger;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure BATTERY_USB_CHARGER_STATUS
Public Type As Integer
Public Reserved As UInteger
Public Flags As UInteger
Public MaxCurrent As UInteger
Public Voltage As UInteger
Public PortType As Integer
Public PortId As ULong
Public PowerSourceInformation As IntPtr
Public OemCharger As Guid
End Structureimport ctypes
from ctypes import wintypes
class BATTERY_USB_CHARGER_STATUS(ctypes.Structure):
_fields_ = [
("Type", ctypes.c_int),
("Reserved", wintypes.DWORD),
("Flags", wintypes.DWORD),
("MaxCurrent", wintypes.DWORD),
("Voltage", wintypes.DWORD),
("PortType", ctypes.c_int),
("PortId", ctypes.c_ulonglong),
("PowerSourceInformation", ctypes.c_void_p),
("OemCharger", GUID),
]#[repr(C)]
pub struct BATTERY_USB_CHARGER_STATUS {
pub Type: i32,
pub Reserved: u32,
pub Flags: u32,
pub MaxCurrent: u32,
pub Voltage: u32,
pub PortType: i32,
pub PortId: u64,
pub PowerSourceInformation: *mut core::ffi::c_void,
pub OemCharger: GUID,
}import "golang.org/x/sys/windows"
type BATTERY_USB_CHARGER_STATUS struct {
Type int32
Reserved uint32
Flags uint32
MaxCurrent uint32
Voltage uint32
PortType int32
PortId uint64
PowerSourceInformation uintptr
OemCharger windows.GUID
}type
BATTERY_USB_CHARGER_STATUS = record
Type: Integer;
Reserved: DWORD;
Flags: DWORD;
MaxCurrent: DWORD;
Voltage: DWORD;
PortType: Integer;
PortId: UInt64;
PowerSourceInformation: Pointer;
OemCharger: TGUID;
end;const BATTERY_USB_CHARGER_STATUS = extern struct {
Type: i32,
Reserved: u32,
Flags: u32,
MaxCurrent: u32,
Voltage: u32,
PortType: i32,
PortId: u64,
PowerSourceInformation: ?*anyopaque,
OemCharger: GUID,
};type
BATTERY_USB_CHARGER_STATUS {.bycopy.} = object
Type: int32
Reserved: uint32
Flags: uint32
MaxCurrent: uint32
Voltage: uint32
PortType: int32
PortId: uint64
PowerSourceInformation: pointer
OemCharger: GUIDstruct BATTERY_USB_CHARGER_STATUS
{
int Type;
uint Reserved;
uint Flags;
uint MaxCurrent;
uint Voltage;
int PortType;
ulong PortId;
void* PowerSourceInformation;
GUID OemCharger;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; BATTERY_USB_CHARGER_STATUS サイズ: 56 バイト(x86)
dim st, 14 ; 4byte整数×14(構造体サイズ 56 / 4 切り上げ)
; Type : BATTERY_CHARGING_SOURCE_TYPE (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; Reserved : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; Flags : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; MaxCurrent : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; Voltage : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; PortType : USB_CHARGER_PORT (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; PortId : ULONGLONG (+24, 8byte) qpoke st,24,値 / qpeek(st,24) ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; PowerSourceInformation : void* (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; OemCharger : GUID (+36, 16byte) varptr(st)+36 を基点に操作(16byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; BATTERY_USB_CHARGER_STATUS サイズ: 56 バイト(x64)
dim st, 14 ; 4byte整数×14(構造体サイズ 56 / 4 切り上げ)
; Type : BATTERY_CHARGING_SOURCE_TYPE (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; Reserved : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; Flags : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; MaxCurrent : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; Voltage : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; PortType : USB_CHARGER_PORT (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; PortId : ULONGLONG (+24, 8byte) qpoke st,24,値 / qpeek(st,24) ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; PowerSourceInformation : void* (+32, 8byte) qpoke st,32,値 / qpeek(st,32) ※IronHSPのみ。3.7/3.8は lpoke st,32,下位 : lpoke st,36,上位
; OemCharger : GUID (+40, 16byte) varptr(st)+40 を基点に操作(16byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global GUID, pack=1
#field int Data1
#field short Data2
#field short Data3
#field byte Data4 8
#endstruct
#defstruct global BATTERY_USB_CHARGER_STATUS
#field int Type
#field int Reserved
#field int Flags
#field int MaxCurrent
#field int Voltage
#field int PortType
#field int64 PortId
#field intptr PowerSourceInformation
#field GUID OemCharger
#endstruct
stdim st, BATTERY_USB_CHARGER_STATUS ; NSTRUCT 変数を確保
st->Type = 100
mes "Type=" + st->Type