Win32 API 日本語リファレンス
ホームStorage.FileSystem › FILE_STORAGE_INFO

FILE_STORAGE_INFO

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

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

フィールド

フィールドサイズx64x86説明
LogicalBytesPerSectorDWORD4+0+0物理ストレージが報告する、セクターあたりの論理バイト数。これは、キャッシュを使用しない I/O が サポートされる最小のサイズです。
PhysicalBytesPerSectorForAtomicityDWORD4+4+4アトミックな書き込みにおけるセクターあたりのバイト数。これより小さい書き込みでは、ブロック全体をアトミックに 書き込む前に読み取りが必要になる場合があります。
PhysicalBytesPerSectorForPerformanceDWORD4+8+8書き込みのパフォーマンスが最適となる、セクターあたりのバイト数。
FileSystemEffectivePhysicalBytesPerSectorForAtomicityDWORD4+12+12これは、ファイルシステムがアトミック性のために使用するブロックのサイズです。これは、物理メディアにとって 最適なサイズと、既存のコードや構造体に適合させやすいサイズとのトレードオフとなる場合があります。
FlagsDWORD4+16+16

このメンバーには、ストレージのアラインメントに関する情報を指定するフラグの組み合わせを 格納できます。

意味
STORAGE_INFO_FLAGS_ALIGNED_DEVICE
0x00000001
このフラグが設定されている場合、ストレージデバイスの論理セクターが物理セクターの境界に アラインされていることを示します。
STORAGE_INFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE
0x00000002
このフラグが設定されている場合、パーティションがストレージデバイス上の物理セクターの境界に アラインされていることを示します。
ByteOffsetForSectorAlignmentDWORD4+20+20最初の論理セクターが配置される、最初の物理セクター内での論理セクターのオフセット (バイト単位)。 この値が STORAGE_INFO_OFFSET_UNKNOWN (0xffffffff) に設定されている場合は、このフィールドを 計算するための情報が不足していたことを示します。
ByteOffsetForPartitionAlignmentDWORD4+24+24ストレージデバイス上でパーティションを物理セクターの境界にアラインするために使用されるオフセット (バイト単位)。 この値が STORAGE_INFO_OFFSET_UNKNOWN (0xffffffff) に設定されている場合は、このフィールドを 計算するための情報が不足していたことを示します。

公式ドキュメント

ファイルのディレクトリ情報を格納します。この構造体は、FileInformationClass パラメーターに FileStorageInfo を渡したときに GetFileInformationByHandleEx 関数から 返されます。

解説(Remarks)

特性の異なるストレージデバイス上にボリュームが構築されている場合 (ミラー、スパン、ストライプ、 RAID 構成など)、返されるサイズは、基になるストレージデバイスのうち最も大きいサイズになります。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での定義

#include <windows.h>

// FILE_STORAGE_INFO  (x64 28 / x86 28 バイト)
typedef struct FILE_STORAGE_INFO {
    DWORD LogicalBytesPerSector;
    DWORD PhysicalBytesPerSectorForAtomicity;
    DWORD PhysicalBytesPerSectorForPerformance;
    DWORD FileSystemEffectivePhysicalBytesPerSectorForAtomicity;
    DWORD Flags;
    DWORD ByteOffsetForSectorAlignment;
    DWORD ByteOffsetForPartitionAlignment;
} FILE_STORAGE_INFO;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct FILE_STORAGE_INFO
{
    public uint LogicalBytesPerSector;
    public uint PhysicalBytesPerSectorForAtomicity;
    public uint PhysicalBytesPerSectorForPerformance;
    public uint FileSystemEffectivePhysicalBytesPerSectorForAtomicity;
    public uint Flags;
    public uint ByteOffsetForSectorAlignment;
    public uint ByteOffsetForPartitionAlignment;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure FILE_STORAGE_INFO
    Public LogicalBytesPerSector As UInteger
    Public PhysicalBytesPerSectorForAtomicity As UInteger
    Public PhysicalBytesPerSectorForPerformance As UInteger
    Public FileSystemEffectivePhysicalBytesPerSectorForAtomicity As UInteger
    Public Flags As UInteger
    Public ByteOffsetForSectorAlignment As UInteger
    Public ByteOffsetForPartitionAlignment As UInteger
End Structure
import ctypes
from ctypes import wintypes

class FILE_STORAGE_INFO(ctypes.Structure):
    _fields_ = [
        ("LogicalBytesPerSector", wintypes.DWORD),
        ("PhysicalBytesPerSectorForAtomicity", wintypes.DWORD),
        ("PhysicalBytesPerSectorForPerformance", wintypes.DWORD),
        ("FileSystemEffectivePhysicalBytesPerSectorForAtomicity", wintypes.DWORD),
        ("Flags", wintypes.DWORD),
        ("ByteOffsetForSectorAlignment", wintypes.DWORD),
        ("ByteOffsetForPartitionAlignment", wintypes.DWORD),
    ]
#[repr(C)]
pub struct FILE_STORAGE_INFO {
    pub LogicalBytesPerSector: u32,
    pub PhysicalBytesPerSectorForAtomicity: u32,
    pub PhysicalBytesPerSectorForPerformance: u32,
    pub FileSystemEffectivePhysicalBytesPerSectorForAtomicity: u32,
    pub Flags: u32,
    pub ByteOffsetForSectorAlignment: u32,
    pub ByteOffsetForPartitionAlignment: u32,
}
import "golang.org/x/sys/windows"

type FILE_STORAGE_INFO struct {
	LogicalBytesPerSector uint32
	PhysicalBytesPerSectorForAtomicity uint32
	PhysicalBytesPerSectorForPerformance uint32
	FileSystemEffectivePhysicalBytesPerSectorForAtomicity uint32
	Flags uint32
	ByteOffsetForSectorAlignment uint32
	ByteOffsetForPartitionAlignment uint32
}
type
  FILE_STORAGE_INFO = record
    LogicalBytesPerSector: DWORD;
    PhysicalBytesPerSectorForAtomicity: DWORD;
    PhysicalBytesPerSectorForPerformance: DWORD;
    FileSystemEffectivePhysicalBytesPerSectorForAtomicity: DWORD;
    Flags: DWORD;
    ByteOffsetForSectorAlignment: DWORD;
    ByteOffsetForPartitionAlignment: DWORD;
  end;
const FILE_STORAGE_INFO = extern struct {
    LogicalBytesPerSector: u32,
    PhysicalBytesPerSectorForAtomicity: u32,
    PhysicalBytesPerSectorForPerformance: u32,
    FileSystemEffectivePhysicalBytesPerSectorForAtomicity: u32,
    Flags: u32,
    ByteOffsetForSectorAlignment: u32,
    ByteOffsetForPartitionAlignment: u32,
};
type
  FILE_STORAGE_INFO {.bycopy.} = object
    LogicalBytesPerSector: uint32
    PhysicalBytesPerSectorForAtomicity: uint32
    PhysicalBytesPerSectorForPerformance: uint32
    FileSystemEffectivePhysicalBytesPerSectorForAtomicity: uint32
    Flags: uint32
    ByteOffsetForSectorAlignment: uint32
    ByteOffsetForPartitionAlignment: uint32
struct FILE_STORAGE_INFO
{
    uint LogicalBytesPerSector;
    uint PhysicalBytesPerSectorForAtomicity;
    uint PhysicalBytesPerSectorForPerformance;
    uint FileSystemEffectivePhysicalBytesPerSectorForAtomicity;
    uint Flags;
    uint ByteOffsetForSectorAlignment;
    uint ByteOffsetForPartitionAlignment;
}

HSP用 定義

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

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

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