ホーム › System.Ioctl › STORAGE_COUNTERS
STORAGE_COUNTERS
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| Version | DWORD | 4 | +0 | +0 | この構造体のバージョン番号。 |
| Size | DWORD | 4 | +4 | +4 | この構造体のバイト単位のサイズ。 |
| NumberOfCounters | DWORD | 4 | +8 | +8 | Counters配列に含まれるカウンタの数。 |
| Counters | STORAGE_COUNTER | 16 | +16 | +16 | STORAGE_COUNTER構造体の可変長配列。先頭要素。 |
各言語での定義
#include <windows.h>
// STORAGE_COUNTER (x64 16 / x86 16 バイト)
typedef struct STORAGE_COUNTER {
STORAGE_COUNTER_TYPE Type;
_Value_e__Union Value;
} STORAGE_COUNTER;
// STORAGE_COUNTERS (x64 32 / x86 32 バイト)
typedef struct STORAGE_COUNTERS {
DWORD Version;
DWORD Size;
DWORD NumberOfCounters;
STORAGE_COUNTER Counters[1];
} STORAGE_COUNTERS;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct STORAGE_COUNTER
{
public int Type;
public _Value_e__Union Value;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct STORAGE_COUNTERS
{
public uint Version;
public uint Size;
public uint NumberOfCounters;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public STORAGE_COUNTER[] Counters;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure STORAGE_COUNTER
Public Type As Integer
Public Value As _Value_e__Union
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure STORAGE_COUNTERS
Public Version As UInteger
Public Size As UInteger
Public NumberOfCounters As UInteger
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public Counters() As STORAGE_COUNTER
End Structureimport ctypes
from ctypes import wintypes
class STORAGE_COUNTER(ctypes.Structure):
_fields_ = [
("Type", ctypes.c_int),
("Value", _Value_e__Union),
]
class STORAGE_COUNTERS(ctypes.Structure):
_fields_ = [
("Version", wintypes.DWORD),
("Size", wintypes.DWORD),
("NumberOfCounters", wintypes.DWORD),
("Counters", STORAGE_COUNTER * 1),
]#[repr(C)]
pub struct STORAGE_COUNTER {
pub Type: i32,
pub Value: _Value_e__Union,
}
#[repr(C)]
pub struct STORAGE_COUNTERS {
pub Version: u32,
pub Size: u32,
pub NumberOfCounters: u32,
pub Counters: [STORAGE_COUNTER; 1],
}import "golang.org/x/sys/windows"
type STORAGE_COUNTER struct {
Type int32
Value _Value_e__Union
}
type STORAGE_COUNTERS struct {
Version uint32
Size uint32
NumberOfCounters uint32
Counters [1]STORAGE_COUNTER
}type
STORAGE_COUNTER = record
Type: Integer;
Value: _Value_e__Union;
end;
STORAGE_COUNTERS = record
Version: DWORD;
Size: DWORD;
NumberOfCounters: DWORD;
Counters: array[0..0] of STORAGE_COUNTER;
end;const STORAGE_COUNTER = extern struct {
Type: i32,
Value: _Value_e__Union,
};
const STORAGE_COUNTERS = extern struct {
Version: u32,
Size: u32,
NumberOfCounters: u32,
Counters: [1]STORAGE_COUNTER,
};type
STORAGE_COUNTER {.bycopy.} = object
Type: int32
Value: _Value_e__Union
STORAGE_COUNTERS {.bycopy.} = object
Version: uint32
Size: uint32
NumberOfCounters: uint32
Counters: array[1, STORAGE_COUNTER]struct STORAGE_COUNTER
{
int Type;
_Value_e__Union Value;
}
struct STORAGE_COUNTERS
{
uint Version;
uint Size;
uint NumberOfCounters;
STORAGE_COUNTER[1] Counters;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; STORAGE_COUNTERS サイズ: 32 バイト(x64)
dim st, 8 ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; Version : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; Size : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; NumberOfCounters : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; Counters : STORAGE_COUNTER (+16, 16byte) varptr(st)+16 を基点に操作(16byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global STORAGE_COUNTER
#field int Type
#field byte Value 8
#endstruct
#defstruct global STORAGE_COUNTERS
#field int Version
#field int Size
#field int NumberOfCounters
#field STORAGE_COUNTER Counters 1
#endstruct
stdim st, STORAGE_COUNTERS ; NSTRUCT 変数を確保
st->Version = 100
mes "Version=" + st->Version