SHFILEINFOW
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| hIcon | HICON | 8/4 | +0 | +0 | ファイルを表すアイコンのハンドルです。不要になった時点で、DestroyIcon を使用してこのハンドルを破棄する責任があります。 |
| iIcon | INT | 4 | +8 | +4 | システムイメージリスト内でのアイコンイメージのインデックスです。 |
| dwAttributes | DWORD | 4 | +12 | +8 | ファイルオブジェクトの属性を示す値の配列です。これらの値については、IShellFolder::GetAttributesOf メソッドを参照してください。 |
| szDisplayName | WCHAR | 520 | +16 | +12 | Windows シェルに表示されるファイル名、またはそのファイルを表すアイコンを含むファイルのパスとファイル名を格納する文字列です。 |
| szTypeName | WCHAR | 160 | +536 | +532 | ファイルの種類を説明する文字列です。 |
公式ドキュメント
ファイルオブジェクトに関する情報を格納します。
解説(Remarks)
この構造体は SHGetFileInfo 関数で使用されます。
メモ
shellapi.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいて、この関数の ANSI 版と Unicode 版を自動的に選択するエイリアスとして SHFILEINFO を定義します。エンコードに中立なエイリアスの使用と、エンコードに中立でないコードを混在させると、不一致が生じてコンパイルエラーや実行時エラーの原因となることがあります。詳細については、関数プロトタイプの規則 を参照してください。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での定義
#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