Win32 API 日本語リファレンス
ホームUI.Shell › FILEDESCRIPTORA

FILEDESCRIPTORA

構造体
サイズx64: 332 バイト / x86: 332 バイトパッキング1

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

フィールド

フィールドサイズx64x86説明
dwFlagsDWORD4+0+0有効なメンバを示すフラグ(FD_定数)。
clsidGUID16+4+4ファイルに関連付けるCLSID。
sizelSIZE8+20+20ファイルアイコンや表示のサイズ(SIZE)。
pointlPOINTL8+28+28ファイルアイコンの表示位置(POINTL)。
dwFileAttributesDWORD4+36+36ファイル属性(FILE_ATTRIBUTE_定数)。
ftCreationTimeFILETIME8+40+40ファイルの作成日時(FILETIME)。
ftLastAccessTimeFILETIME8+48+48ファイルの最終アクセス日時(FILETIME)。
ftLastWriteTimeFILETIME8+56+56ファイルの最終更新日時(FILETIME)。
nFileSizeHighDWORD4+64+64ファイルサイズの上位32ビット。
nFileSizeLowDWORD4+68+68ファイルサイズの下位32ビット。
cFileNameCHAR260+72+72ファイル名(ANSI固定長配列)。

各言語での定義

#include <windows.h>

// SIZE  (x64 8 / x86 8 バイト)
typedef struct SIZE {
    INT cx;
    INT cy;
} SIZE;

// POINTL  (x64 8 / x86 8 バイト)
typedef struct POINTL {
    INT x;
    INT y;
} POINTL;

// FILETIME  (x64 8 / x86 8 バイト)
typedef struct FILETIME {
    DWORD dwLowDateTime;
    DWORD dwHighDateTime;
} FILETIME;

// FILEDESCRIPTORA  (x64 332 / x86 332 バイト)
#pragma pack(push, 1)
typedef struct FILEDESCRIPTORA {
    DWORD dwFlags;
    GUID clsid;
    SIZE sizel;
    POINTL pointl;
    DWORD dwFileAttributes;
    FILETIME ftCreationTime;
    FILETIME ftLastAccessTime;
    FILETIME ftLastWriteTime;
    DWORD nFileSizeHigh;
    DWORD nFileSizeLow;
    CHAR cFileName[260];
} FILEDESCRIPTORA;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SIZE
{
    public int cx;
    public int cy;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct POINTL
{
    public int x;
    public int y;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct FILETIME
{
    public uint dwLowDateTime;
    public uint dwHighDateTime;
}

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct FILEDESCRIPTORA
{
    public uint dwFlags;
    public Guid clsid;
    public SIZE sizel;
    public POINTL pointl;
    public uint dwFileAttributes;
    public FILETIME ftCreationTime;
    public FILETIME ftLastAccessTime;
    public FILETIME ftLastWriteTime;
    public uint nFileSizeHigh;
    public uint nFileSizeLow;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 260)] public sbyte[] cFileName;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SIZE
    Public cx As Integer
    Public cy As Integer
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure POINTL
    Public x As Integer
    Public y As Integer
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure FILETIME
    Public dwLowDateTime As UInteger
    Public dwHighDateTime As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure FILEDESCRIPTORA
    Public dwFlags As UInteger
    Public clsid As Guid
    Public sizel As SIZE
    Public pointl As POINTL
    Public dwFileAttributes As UInteger
    Public ftCreationTime As FILETIME
    Public ftLastAccessTime As FILETIME
    Public ftLastWriteTime As FILETIME
    Public nFileSizeHigh As UInteger
    Public nFileSizeLow As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=260)> Public cFileName() As SByte
End Structure
import ctypes
from ctypes import wintypes

class SIZE(ctypes.Structure):
    _fields_ = [
        ("cx", ctypes.c_int),
        ("cy", ctypes.c_int),
    ]

class POINTL(ctypes.Structure):
    _fields_ = [
        ("x", ctypes.c_int),
        ("y", ctypes.c_int),
    ]

class FILETIME(ctypes.Structure):
    _fields_ = [
        ("dwLowDateTime", wintypes.DWORD),
        ("dwHighDateTime", wintypes.DWORD),
    ]

class FILEDESCRIPTORA(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("dwFlags", wintypes.DWORD),
        ("clsid", GUID),
        ("sizel", SIZE),
        ("pointl", POINTL),
        ("dwFileAttributes", wintypes.DWORD),
        ("ftCreationTime", FILETIME),
        ("ftLastAccessTime", FILETIME),
        ("ftLastWriteTime", FILETIME),
        ("nFileSizeHigh", wintypes.DWORD),
        ("nFileSizeLow", wintypes.DWORD),
        ("cFileName", ctypes.c_byte * 260),
    ]
#[repr(C)]
pub struct SIZE {
    pub cx: i32,
    pub cy: i32,
}

#[repr(C)]
pub struct POINTL {
    pub x: i32,
    pub y: i32,
}

#[repr(C)]
pub struct FILETIME {
    pub dwLowDateTime: u32,
    pub dwHighDateTime: u32,
}

#[repr(C, packed(1))]
pub struct FILEDESCRIPTORA {
    pub dwFlags: u32,
    pub clsid: GUID,
    pub sizel: SIZE,
    pub pointl: POINTL,
    pub dwFileAttributes: u32,
    pub ftCreationTime: FILETIME,
    pub ftLastAccessTime: FILETIME,
    pub ftLastWriteTime: FILETIME,
    pub nFileSizeHigh: u32,
    pub nFileSizeLow: u32,
    pub cFileName: [i8; 260],
}
import "golang.org/x/sys/windows"

type SIZE struct {
	cx int32
	cy int32
}

type POINTL struct {
	x int32
	y int32
}

type FILETIME struct {
	dwLowDateTime uint32
	dwHighDateTime uint32
}

type FILEDESCRIPTORA struct {
	dwFlags uint32
	clsid windows.GUID
	sizel SIZE
	pointl POINTL
	dwFileAttributes uint32
	ftCreationTime FILETIME
	ftLastAccessTime FILETIME
	ftLastWriteTime FILETIME
	nFileSizeHigh uint32
	nFileSizeLow uint32
	cFileName [260]int8
}
type
  SIZE = record
    cx: Integer;
    cy: Integer;
  end;

  POINTL = record
    x: Integer;
    y: Integer;
  end;

  FILETIME = record
    dwLowDateTime: DWORD;
    dwHighDateTime: DWORD;
  end;

  FILEDESCRIPTORA = packed record
    dwFlags: DWORD;
    clsid: TGUID;
    sizel: SIZE;
    pointl: POINTL;
    dwFileAttributes: DWORD;
    ftCreationTime: FILETIME;
    ftLastAccessTime: FILETIME;
    ftLastWriteTime: FILETIME;
    nFileSizeHigh: DWORD;
    nFileSizeLow: DWORD;
    cFileName: array[0..259] of Shortint;
  end;
const SIZE = extern struct {
    cx: i32,
    cy: i32,
};

const POINTL = extern struct {
    x: i32,
    y: i32,
};

const FILETIME = extern struct {
    dwLowDateTime: u32,
    dwHighDateTime: u32,
};

const FILEDESCRIPTORA = extern struct {
    dwFlags: u32,
    clsid: GUID,
    sizel: SIZE,
    pointl: POINTL,
    dwFileAttributes: u32,
    ftCreationTime: FILETIME,
    ftLastAccessTime: FILETIME,
    ftLastWriteTime: FILETIME,
    nFileSizeHigh: u32,
    nFileSizeLow: u32,
    cFileName: [260]i8,
};
type
  SIZE {.bycopy.} = object
    cx: int32
    cy: int32

  POINTL {.bycopy.} = object
    x: int32
    y: int32

  FILETIME {.bycopy.} = object
    dwLowDateTime: uint32
    dwHighDateTime: uint32

  FILEDESCRIPTORA {.packed.} = object
    dwFlags: uint32
    clsid: GUID
    sizel: SIZE
    pointl: POINTL
    dwFileAttributes: uint32
    ftCreationTime: FILETIME
    ftLastAccessTime: FILETIME
    ftLastWriteTime: FILETIME
    nFileSizeHigh: uint32
    nFileSizeLow: uint32
    cFileName: array[260, int8]
struct SIZE
{
    int cx;
    int cy;
}

struct POINTL
{
    int x;
    int y;
}

struct FILETIME
{
    uint dwLowDateTime;
    uint dwHighDateTime;
}

align(1)
struct FILEDESCRIPTORA
{
    uint dwFlags;
    GUID clsid;
    SIZE sizel;
    POINTL pointl;
    uint dwFileAttributes;
    FILETIME ftCreationTime;
    FILETIME ftLastAccessTime;
    FILETIME ftLastWriteTime;
    uint nFileSizeHigh;
    uint nFileSizeLow;
    byte[260] cFileName;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; FILEDESCRIPTORA サイズ: 332 バイト(x64)
dim st, 83    ; 4byte整数×83(構造体サイズ 332 / 4 切り上げ)
; dwFlags : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; clsid : GUID (+4, 16byte)  varptr(st)+4 を基点に操作(16byte:入れ子/配列)
; sizel : SIZE (+20, 8byte)  varptr(st)+20 を基点に操作(8byte:入れ子/配列)
; pointl : POINTL (+28, 8byte)  varptr(st)+28 を基点に操作(8byte:入れ子/配列)
; dwFileAttributes : DWORD (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; ftCreationTime : FILETIME (+40, 8byte)  varptr(st)+40 を基点に操作(8byte:入れ子/配列)
; ftLastAccessTime : FILETIME (+48, 8byte)  varptr(st)+48 を基点に操作(8byte:入れ子/配列)
; ftLastWriteTime : FILETIME (+56, 8byte)  varptr(st)+56 を基点に操作(8byte:入れ子/配列)
; nFileSizeHigh : DWORD (+64, 4byte)  st.16 = 値  /  値 = st.16   (lpoke/lpeek も可)
; nFileSizeLow : DWORD (+68, 4byte)  st.17 = 値  /  値 = st.17   (lpoke/lpeek も可)
; cFileName : CHAR (+72, 260byte)  varptr(st)+72 を基点に操作(260byte:入れ子/配列)
; ※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 SIZE
    #field int cx
    #field int cy
#endstruct

#defstruct global POINTL
    #field int x
    #field int y
#endstruct

#defstruct global FILETIME
    #field int dwLowDateTime
    #field int dwHighDateTime
#endstruct

#defstruct global FILEDESCRIPTORA, pack=1
    #field int dwFlags
    #field GUID clsid
    #field SIZE sizel
    #field POINTL pointl
    #field int dwFileAttributes
    #field FILETIME ftCreationTime
    #field FILETIME ftLastAccessTime
    #field FILETIME ftLastWriteTime
    #field int nFileSizeHigh
    #field int nFileSizeLow
    #field byte cFileName 260
#endstruct

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