SHFILEINFOA
構造体サイズ=各フィールドのバイト数(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 | CHAR | 260 | +16 | +12 | ファイルの表示名を格納する文字列(ANSI)。 |
| szTypeName | CHAR | 80 | +276 | +272 | ファイル種類の名称を格納する文字列(ANSI)。 |
各言語での定義
#include <windows.h>
// SHFILEINFOA (x64 356 / x86 352 バイト)
#pragma pack(push, 1)
typedef struct SHFILEINFOA {
HICON hIcon;
INT iIcon;
DWORD dwAttributes;
CHAR szDisplayName[260];
CHAR szTypeName[80];
} SHFILEINFOA;
#pragma pack(pop)using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct SHFILEINFOA
{
public IntPtr hIcon;
public int iIcon;
public uint dwAttributes;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 260)] public sbyte[] szDisplayName;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 80)] public sbyte[] szTypeName;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure SHFILEINFOA
Public hIcon As IntPtr
Public iIcon As Integer
Public dwAttributes As UInteger
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=260)> Public szDisplayName() As SByte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=80)> Public szTypeName() As SByte
End Structureimport ctypes
from ctypes import wintypes
class SHFILEINFOA(ctypes.Structure):
_pack_ = 1
_fields_ = [
("hIcon", ctypes.c_void_p),
("iIcon", ctypes.c_int),
("dwAttributes", wintypes.DWORD),
("szDisplayName", ctypes.c_byte * 260),
("szTypeName", ctypes.c_byte * 80),
]#[repr(C, packed(1))]
pub struct SHFILEINFOA {
pub hIcon: *mut core::ffi::c_void,
pub iIcon: i32,
pub dwAttributes: u32,
pub szDisplayName: [i8; 260],
pub szTypeName: [i8; 80],
}import "golang.org/x/sys/windows"
type SHFILEINFOA struct {
hIcon uintptr
iIcon int32
dwAttributes uint32
szDisplayName [260]int8
szTypeName [80]int8
}type
SHFILEINFOA = packed record
hIcon: Pointer;
iIcon: Integer;
dwAttributes: DWORD;
szDisplayName: array[0..259] of Shortint;
szTypeName: array[0..79] of Shortint;
end;const SHFILEINFOA = extern struct {
hIcon: ?*anyopaque,
iIcon: i32,
dwAttributes: u32,
szDisplayName: [260]i8,
szTypeName: [80]i8,
};type
SHFILEINFOA {.packed.} = object
hIcon: pointer
iIcon: int32
dwAttributes: uint32
szDisplayName: array[260, int8]
szTypeName: array[80, int8]align(1)
struct SHFILEINFOA
{
void* hIcon;
int iIcon;
uint dwAttributes;
byte[260] szDisplayName;
byte[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 レイアウト)
; SHFILEINFOA サイズ: 352 バイト(x86)
dim st, 88 ; 4byte整数×88(構造体サイズ 352 / 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 : CHAR (+12, 260byte) varptr(st)+12 を基点に操作(260byte:入れ子/配列)
; szTypeName : CHAR (+272, 80byte) varptr(st)+272 を基点に操作(80byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; SHFILEINFOA サイズ: 356 バイト(x64)
dim st, 89 ; 4byte整数×89(構造体サイズ 356 / 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 : CHAR (+16, 260byte) varptr(st)+16 を基点に操作(260byte:入れ子/配列)
; szTypeName : CHAR (+276, 80byte) varptr(st)+276 を基点に操作(80byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global SHFILEINFOA, pack=1
#field intptr hIcon
#field int iIcon
#field int dwAttributes
#field byte szDisplayName 260
#field byte szTypeName 80
#endstruct
stdim st, SHFILEINFOA ; NSTRUCT 変数を確保
st->iIcon = 100
mes "iIcon=" + st->iIcon