SHFILEINFOW
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| hIcon | HICON | 8/4 | +0 | +0 | ファイルに関連付けられたアイコンのハンドル。 |
| iIcon | INT | 4 | +8 | +4 | システムイメージリスト内のアイコンインデックス。 |
| dwAttributes | DWORD | 4 | +12 | +8 | ファイルの属性を示すフラグ(SFGAO_ 系)。 |
| szDisplayName | WCHAR | 520 | +16 | +12 | ファイルの表示名を格納する文字列(Unicode)。 |
| szTypeName | WCHAR | 160 | +536 | +532 | ファイル種類の名称を格納する文字列(Unicode)。 |
各言語での定義
#include <windows.h>
// SHFILEINFOW (x64 696 / x86 692 バイト)
#pragma pack(push, 1)
typedef struct SHFILEINFOW {
HICON hIcon;
INT iIcon;
DWORD dwAttributes;
WCHAR szDisplayName[260];
WCHAR szTypeName[80];
} SHFILEINFOW;
#pragma pack(pop)using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct SHFILEINFOW
{
public IntPtr hIcon;
public int iIcon;
public uint dwAttributes;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] public string szDisplayName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)] public string szTypeName;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure SHFILEINFOW
Public hIcon As IntPtr
Public iIcon As Integer
Public dwAttributes As UInteger
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=260)> Public szDisplayName As String
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=80)> Public szTypeName As String
End Structureimport ctypes
from ctypes import wintypes
class SHFILEINFOW(ctypes.Structure):
_pack_ = 1
_fields_ = [
("hIcon", ctypes.c_void_p),
("iIcon", ctypes.c_int),
("dwAttributes", wintypes.DWORD),
("szDisplayName", ctypes.c_wchar * 260),
("szTypeName", ctypes.c_wchar * 80),
]#[repr(C, packed(1))]
pub struct SHFILEINFOW {
pub hIcon: *mut core::ffi::c_void,
pub iIcon: i32,
pub dwAttributes: u32,
pub szDisplayName: [u16; 260],
pub szTypeName: [u16; 80],
}import "golang.org/x/sys/windows"
type SHFILEINFOW struct {
hIcon uintptr
iIcon int32
dwAttributes uint32
szDisplayName [260]uint16
szTypeName [80]uint16
}type
SHFILEINFOW = packed record
hIcon: Pointer;
iIcon: Integer;
dwAttributes: DWORD;
szDisplayName: array[0..259] of WideChar;
szTypeName: array[0..79] of WideChar;
end;const SHFILEINFOW = extern struct {
hIcon: ?*anyopaque,
iIcon: i32,
dwAttributes: u32,
szDisplayName: [260]u16,
szTypeName: [80]u16,
};type
SHFILEINFOW {.packed.} = object
hIcon: pointer
iIcon: int32
dwAttributes: uint32
szDisplayName: array[260, uint16]
szTypeName: array[80, uint16]align(1)
struct SHFILEINFOW
{
void* hIcon;
int iIcon;
uint dwAttributes;
wchar[260] szDisplayName;
wchar[80] szTypeName;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; SHFILEINFOW サイズ: 692 バイト(x86)
dim st, 173 ; 4byte整数×173(構造体サイズ 692 / 4 切り上げ)
; hIcon : HICON (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; iIcon : INT (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; dwAttributes : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; szDisplayName : WCHAR (+12, 520byte) varptr(st)+12 を基点に操作(520byte:入れ子/配列)
; szTypeName : WCHAR (+532, 160byte) varptr(st)+532 を基点に操作(160byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; SHFILEINFOW サイズ: 696 バイト(x64)
dim st, 174 ; 4byte整数×174(構造体サイズ 696 / 4 切り上げ)
; hIcon : HICON (+0, 8byte) qpoke st,0,値 / qpeek(st,0) ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; iIcon : INT (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; dwAttributes : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; szDisplayName : WCHAR (+16, 520byte) varptr(st)+16 を基点に操作(520byte:入れ子/配列)
; szTypeName : WCHAR (+536, 160byte) varptr(st)+536 を基点に操作(160byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global SHFILEINFOW, pack=1
#field intptr hIcon
#field int iIcon
#field int dwAttributes
#field wchar szDisplayName 260
#field wchar szTypeName 80
#endstruct
stdim st, SHFILEINFOW ; NSTRUCT 変数を確保
st->iIcon = 100
mes "iIcon=" + st->iIcon