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

STORAGE_WRITE_CACHE_PROPERTY

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

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

フィールド

フィールドサイズx64x86説明
VersionDWORD4+0+0構造体のバージョン番号。
SizeDWORD4+4+4この構造体のサイズをバイト単位で示す。
WriteCacheTypeWRITE_CACHE_TYPE4+8+8ライトキャッシュの種類を示すWRITE_CACHE_TYPE列挙値。
WriteCacheEnabledWRITE_CACHE_ENABLE4+12+12ライトキャッシュが有効かを示すWRITE_CACHE_ENABLE列挙値。
WriteCacheChangeableWRITE_CACHE_CHANGE4+16+16ライトキャッシュ設定を変更可能かを示すWRITE_CACHE_CHANGE列挙値。
WriteThroughSupportedWRITE_THROUGH4+20+20ライトスルーをサポートするかを示すWRITE_THROUGH列挙値。
FlushCacheSupportedBOOLEAN1+24+24キャッシュフラッシュをサポートするかを示す真偽値。
UserDefinedPowerProtectionBOOLEAN1+25+25ユーザー定義の電源保護があるかを示す真偽値。
NVCacheEnabledBOOLEAN1+26+26不揮発性キャッシュが有効かを示す真偽値。

各言語での定義

#include <windows.h>

// STORAGE_WRITE_CACHE_PROPERTY  (x64 28 / x86 28 バイト)
typedef struct STORAGE_WRITE_CACHE_PROPERTY {
    DWORD Version;
    DWORD Size;
    WRITE_CACHE_TYPE WriteCacheType;
    WRITE_CACHE_ENABLE WriteCacheEnabled;
    WRITE_CACHE_CHANGE WriteCacheChangeable;
    WRITE_THROUGH WriteThroughSupported;
    BOOLEAN FlushCacheSupported;
    BOOLEAN UserDefinedPowerProtection;
    BOOLEAN NVCacheEnabled;
} STORAGE_WRITE_CACHE_PROPERTY;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct STORAGE_WRITE_CACHE_PROPERTY
{
    public uint Version;
    public uint Size;
    public int WriteCacheType;
    public int WriteCacheEnabled;
    public int WriteCacheChangeable;
    public int WriteThroughSupported;
    [MarshalAs(UnmanagedType.U1)] public bool FlushCacheSupported;
    [MarshalAs(UnmanagedType.U1)] public bool UserDefinedPowerProtection;
    [MarshalAs(UnmanagedType.U1)] public bool NVCacheEnabled;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure STORAGE_WRITE_CACHE_PROPERTY
    Public Version As UInteger
    Public Size As UInteger
    Public WriteCacheType As Integer
    Public WriteCacheEnabled As Integer
    Public WriteCacheChangeable As Integer
    Public WriteThroughSupported As Integer
    <MarshalAs(UnmanagedType.U1)> Public FlushCacheSupported As Boolean
    <MarshalAs(UnmanagedType.U1)> Public UserDefinedPowerProtection As Boolean
    <MarshalAs(UnmanagedType.U1)> Public NVCacheEnabled As Boolean
End Structure
import ctypes
from ctypes import wintypes

class STORAGE_WRITE_CACHE_PROPERTY(ctypes.Structure):
    _fields_ = [
        ("Version", wintypes.DWORD),
        ("Size", wintypes.DWORD),
        ("WriteCacheType", ctypes.c_int),
        ("WriteCacheEnabled", ctypes.c_int),
        ("WriteCacheChangeable", ctypes.c_int),
        ("WriteThroughSupported", ctypes.c_int),
        ("FlushCacheSupported", ctypes.c_byte),
        ("UserDefinedPowerProtection", ctypes.c_byte),
        ("NVCacheEnabled", ctypes.c_byte),
    ]
#[repr(C)]
pub struct STORAGE_WRITE_CACHE_PROPERTY {
    pub Version: u32,
    pub Size: u32,
    pub WriteCacheType: i32,
    pub WriteCacheEnabled: i32,
    pub WriteCacheChangeable: i32,
    pub WriteThroughSupported: i32,
    pub FlushCacheSupported: u8,
    pub UserDefinedPowerProtection: u8,
    pub NVCacheEnabled: u8,
}
import "golang.org/x/sys/windows"

type STORAGE_WRITE_CACHE_PROPERTY struct {
	Version uint32
	Size uint32
	WriteCacheType int32
	WriteCacheEnabled int32
	WriteCacheChangeable int32
	WriteThroughSupported int32
	FlushCacheSupported byte
	UserDefinedPowerProtection byte
	NVCacheEnabled byte
}
type
  STORAGE_WRITE_CACHE_PROPERTY = record
    Version: DWORD;
    Size: DWORD;
    WriteCacheType: Integer;
    WriteCacheEnabled: Integer;
    WriteCacheChangeable: Integer;
    WriteThroughSupported: Integer;
    FlushCacheSupported: ByteBool;
    UserDefinedPowerProtection: ByteBool;
    NVCacheEnabled: ByteBool;
  end;
const STORAGE_WRITE_CACHE_PROPERTY = extern struct {
    Version: u32,
    Size: u32,
    WriteCacheType: i32,
    WriteCacheEnabled: i32,
    WriteCacheChangeable: i32,
    WriteThroughSupported: i32,
    FlushCacheSupported: u8,
    UserDefinedPowerProtection: u8,
    NVCacheEnabled: u8,
};
type
  STORAGE_WRITE_CACHE_PROPERTY {.bycopy.} = object
    Version: uint32
    Size: uint32
    WriteCacheType: int32
    WriteCacheEnabled: int32
    WriteCacheChangeable: int32
    WriteThroughSupported: int32
    FlushCacheSupported: uint8
    UserDefinedPowerProtection: uint8
    NVCacheEnabled: uint8
struct STORAGE_WRITE_CACHE_PROPERTY
{
    uint Version;
    uint Size;
    int WriteCacheType;
    int WriteCacheEnabled;
    int WriteCacheChangeable;
    int WriteThroughSupported;
    ubyte FlushCacheSupported;
    ubyte UserDefinedPowerProtection;
    ubyte NVCacheEnabled;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; STORAGE_WRITE_CACHE_PROPERTY サイズ: 28 バイト(x64)
dim st, 7    ; 4byte整数×7(構造体サイズ 28 / 4 切り上げ)
; Version : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; Size : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; WriteCacheType : WRITE_CACHE_TYPE (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; WriteCacheEnabled : WRITE_CACHE_ENABLE (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; WriteCacheChangeable : WRITE_CACHE_CHANGE (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; WriteThroughSupported : WRITE_THROUGH (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; FlushCacheSupported : BOOLEAN (+24, 1byte)  poke st,24,値  /  値 = peek(st,24)
; UserDefinedPowerProtection : BOOLEAN (+25, 1byte)  poke st,25,値  /  値 = peek(st,25)
; NVCacheEnabled : BOOLEAN (+26, 1byte)  poke st,26,値  /  値 = peek(st,26)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global STORAGE_WRITE_CACHE_PROPERTY
    #field int Version
    #field int Size
    #field int WriteCacheType
    #field int WriteCacheEnabled
    #field int WriteCacheChangeable
    #field int WriteThroughSupported
    #field bool1 FlushCacheSupported
    #field bool1 UserDefinedPowerProtection
    #field bool1 NVCacheEnabled
#endstruct

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