ホーム › UI.Controls.Dialogs › OPENFILENAMEA
OPENFILENAMEA
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| lStructSize | DWORD | 4 | +0 | +0 | この構造体のサイズをバイト単位で指定する。GetOpenFileNameA等の呼び出し前に設定する。 |
| hwndOwner | HWND | 8/4 | +4 | +4 | ダイアログを所有する親ウィンドウのハンドル。NULL可。 |
| hInstance | HINSTANCE | 8/4 | +12 | +8 | カスタムテンプレートを含むモジュールのインスタンスハンドル。 |
| lpstrFilter | LPSTR | 8/4 | +20 | +12 | ファイル種別フィルタを表すヌル区切り文字列のペア。最後は二重ヌルで終端する。NULL可。 |
| lpstrCustomFilter | LPSTR | 8/4 | +28 | +16 | ユーザー選択フィルタを保持する文字列バッファ。NULL可。 |
| nMaxCustFilter | DWORD | 4 | +36 | +20 | lpstrCustomFilterバッファのサイズを文字数で指定する。 |
| nFilterIndex | DWORD | 4 | +40 | +24 | 初期選択するフィルタの1始まりのインデックス。0はカスタムフィルタを示す。 |
| lpstrFile | LPSTR | 8/4 | +44 | +28 | 初期ファイル名と選択結果のフルパスを保持するバッファ。複数選択時はヌル区切り。 |
| nMaxFile | DWORD | 4 | +52 | +32 | lpstrFileバッファのサイズを文字数で指定する。 |
| lpstrFileTitle | LPSTR | 8/4 | +56 | +36 | 選択ファイルのファイル名部分(パスなし)を受け取るバッファ。NULL可。 |
| nMaxFileTitle | DWORD | 4 | +64 | +40 | lpstrFileTitleバッファのサイズを文字数で指定する。 |
| lpstrInitialDir | LPSTR | 8/4 | +68 | +44 | 初期表示するディレクトリのパス。NULL可。 |
| lpstrTitle | LPSTR | 8/4 | +76 | +48 | ダイアログのタイトルバーに表示する文字列。NULL可。 |
| Flags | OPEN_FILENAME_FLAGS | 4 | +84 | +52 | ダイアログの動作を制御するOFN_系フラグの組み合わせ。 |
| nFileOffset | WORD | 2 | +88 | +56 | lpstrFile内でファイル名が始まる位置を文字単位で受け取る。 |
| nFileExtension | WORD | 2 | +90 | +58 | lpstrFile内で拡張子が始まる位置を文字単位で受け取る。 |
| lpstrDefExt | LPSTR | 8/4 | +92 | +60 | 拡張子省略時に付加される既定の拡張子。先頭ピリオドなし。NULL可。 |
| lCustData | LPARAM | 8/4 | +100 | +64 | フックプロシージャに渡されるアプリケーション定義データ。 |
| lpfnHook | LPOFNHOOKPROC | 8/4 | +108 | +68 | メッセージを処理するフックプロシージャへのポインタ。OFN_ENABLEHOOK時に有効。 |
| lpTemplateName | LPSTR | 8/4 | +116 | +72 | OFN_ENABLETEMPLATE指定時のダイアログテンプレートのリソース名。 |
| pvReserved | void* | 8/4 | +124 | +76 | 予約フィールド。NULLを指定する。 |
| dwReserved | DWORD | 4 | +132 | +80 | 予約フィールド。0を指定する。 |
| FlagsEx | OPEN_FILENAME_FLAGS_EX | 4 | +136 | +84 | 拡張動作を制御するOFN_EX_系フラグ。OFN_EX_NOPLACESBAR等を指定する。 |
各言語での定義
#include <windows.h>
// OPENFILENAMEA (x64 140 / x86 88 バイト)
#pragma pack(push, 1)
typedef struct OPENFILENAMEA {
DWORD lStructSize;
HWND hwndOwner;
HINSTANCE hInstance;
LPSTR lpstrFilter;
LPSTR lpstrCustomFilter;
DWORD nMaxCustFilter;
DWORD nFilterIndex;
LPSTR lpstrFile;
DWORD nMaxFile;
LPSTR lpstrFileTitle;
DWORD nMaxFileTitle;
LPSTR lpstrInitialDir;
LPSTR lpstrTitle;
OPEN_FILENAME_FLAGS Flags;
WORD nFileOffset;
WORD nFileExtension;
LPSTR lpstrDefExt;
LPARAM lCustData;
LPOFNHOOKPROC lpfnHook;
LPSTR lpTemplateName;
void* pvReserved;
DWORD dwReserved;
OPEN_FILENAME_FLAGS_EX FlagsEx;
} OPENFILENAMEA;
#pragma pack(pop)using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct OPENFILENAMEA
{
public uint lStructSize;
public IntPtr hwndOwner;
public IntPtr hInstance;
public IntPtr lpstrFilter;
public IntPtr lpstrCustomFilter;
public uint nMaxCustFilter;
public uint nFilterIndex;
public IntPtr lpstrFile;
public uint nMaxFile;
public IntPtr lpstrFileTitle;
public uint nMaxFileTitle;
public IntPtr lpstrInitialDir;
public IntPtr lpstrTitle;
public uint Flags;
public ushort nFileOffset;
public ushort nFileExtension;
public IntPtr lpstrDefExt;
public IntPtr lCustData;
public IntPtr lpfnHook;
public IntPtr lpTemplateName;
public IntPtr pvReserved;
public uint dwReserved;
public uint FlagsEx;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure OPENFILENAMEA
Public lStructSize As UInteger
Public hwndOwner As IntPtr
Public hInstance As IntPtr
Public lpstrFilter As IntPtr
Public lpstrCustomFilter As IntPtr
Public nMaxCustFilter As UInteger
Public nFilterIndex As UInteger
Public lpstrFile As IntPtr
Public nMaxFile As UInteger
Public lpstrFileTitle As IntPtr
Public nMaxFileTitle As UInteger
Public lpstrInitialDir As IntPtr
Public lpstrTitle As IntPtr
Public Flags As UInteger
Public nFileOffset As UShort
Public nFileExtension As UShort
Public lpstrDefExt As IntPtr
Public lCustData As IntPtr
Public lpfnHook As IntPtr
Public lpTemplateName As IntPtr
Public pvReserved As IntPtr
Public dwReserved As UInteger
Public FlagsEx As UInteger
End Structureimport ctypes
from ctypes import wintypes
class OPENFILENAMEA(ctypes.Structure):
_pack_ = 1
_fields_ = [
("lStructSize", wintypes.DWORD),
("hwndOwner", ctypes.c_void_p),
("hInstance", ctypes.c_void_p),
("lpstrFilter", ctypes.c_void_p),
("lpstrCustomFilter", ctypes.c_void_p),
("nMaxCustFilter", wintypes.DWORD),
("nFilterIndex", wintypes.DWORD),
("lpstrFile", ctypes.c_void_p),
("nMaxFile", wintypes.DWORD),
("lpstrFileTitle", ctypes.c_void_p),
("nMaxFileTitle", wintypes.DWORD),
("lpstrInitialDir", ctypes.c_void_p),
("lpstrTitle", ctypes.c_void_p),
("Flags", wintypes.DWORD),
("nFileOffset", ctypes.c_ushort),
("nFileExtension", ctypes.c_ushort),
("lpstrDefExt", ctypes.c_void_p),
("lCustData", ctypes.c_ssize_t),
("lpfnHook", ctypes.c_void_p),
("lpTemplateName", ctypes.c_void_p),
("pvReserved", ctypes.c_void_p),
("dwReserved", wintypes.DWORD),
("FlagsEx", wintypes.DWORD),
]#[repr(C, packed(1))]
pub struct OPENFILENAMEA {
pub lStructSize: u32,
pub hwndOwner: *mut core::ffi::c_void,
pub hInstance: *mut core::ffi::c_void,
pub lpstrFilter: *mut core::ffi::c_void,
pub lpstrCustomFilter: *mut core::ffi::c_void,
pub nMaxCustFilter: u32,
pub nFilterIndex: u32,
pub lpstrFile: *mut core::ffi::c_void,
pub nMaxFile: u32,
pub lpstrFileTitle: *mut core::ffi::c_void,
pub nMaxFileTitle: u32,
pub lpstrInitialDir: *mut core::ffi::c_void,
pub lpstrTitle: *mut core::ffi::c_void,
pub Flags: u32,
pub nFileOffset: u16,
pub nFileExtension: u16,
pub lpstrDefExt: *mut core::ffi::c_void,
pub lCustData: isize,
pub lpfnHook: *mut core::ffi::c_void,
pub lpTemplateName: *mut core::ffi::c_void,
pub pvReserved: *mut core::ffi::c_void,
pub dwReserved: u32,
pub FlagsEx: u32,
}import "golang.org/x/sys/windows"
type OPENFILENAMEA struct {
lStructSize uint32
hwndOwner uintptr
hInstance uintptr
lpstrFilter uintptr
lpstrCustomFilter uintptr
nMaxCustFilter uint32
nFilterIndex uint32
lpstrFile uintptr
nMaxFile uint32
lpstrFileTitle uintptr
nMaxFileTitle uint32
lpstrInitialDir uintptr
lpstrTitle uintptr
Flags uint32
nFileOffset uint16
nFileExtension uint16
lpstrDefExt uintptr
lCustData uintptr
lpfnHook uintptr
lpTemplateName uintptr
pvReserved uintptr
dwReserved uint32
FlagsEx uint32
}type
OPENFILENAMEA = packed record
lStructSize: DWORD;
hwndOwner: Pointer;
hInstance: Pointer;
lpstrFilter: Pointer;
lpstrCustomFilter: Pointer;
nMaxCustFilter: DWORD;
nFilterIndex: DWORD;
lpstrFile: Pointer;
nMaxFile: DWORD;
lpstrFileTitle: Pointer;
nMaxFileTitle: DWORD;
lpstrInitialDir: Pointer;
lpstrTitle: Pointer;
Flags: DWORD;
nFileOffset: Word;
nFileExtension: Word;
lpstrDefExt: Pointer;
lCustData: NativeInt;
lpfnHook: Pointer;
lpTemplateName: Pointer;
pvReserved: Pointer;
dwReserved: DWORD;
FlagsEx: DWORD;
end;const OPENFILENAMEA = extern struct {
lStructSize: u32,
hwndOwner: ?*anyopaque,
hInstance: ?*anyopaque,
lpstrFilter: ?*anyopaque,
lpstrCustomFilter: ?*anyopaque,
nMaxCustFilter: u32,
nFilterIndex: u32,
lpstrFile: ?*anyopaque,
nMaxFile: u32,
lpstrFileTitle: ?*anyopaque,
nMaxFileTitle: u32,
lpstrInitialDir: ?*anyopaque,
lpstrTitle: ?*anyopaque,
Flags: u32,
nFileOffset: u16,
nFileExtension: u16,
lpstrDefExt: ?*anyopaque,
lCustData: isize,
lpfnHook: ?*anyopaque,
lpTemplateName: ?*anyopaque,
pvReserved: ?*anyopaque,
dwReserved: u32,
FlagsEx: u32,
};type
OPENFILENAMEA {.packed.} = object
lStructSize: uint32
hwndOwner: pointer
hInstance: pointer
lpstrFilter: pointer
lpstrCustomFilter: pointer
nMaxCustFilter: uint32
nFilterIndex: uint32
lpstrFile: pointer
nMaxFile: uint32
lpstrFileTitle: pointer
nMaxFileTitle: uint32
lpstrInitialDir: pointer
lpstrTitle: pointer
Flags: uint32
nFileOffset: uint16
nFileExtension: uint16
lpstrDefExt: pointer
lCustData: int
lpfnHook: pointer
lpTemplateName: pointer
pvReserved: pointer
dwReserved: uint32
FlagsEx: uint32align(1)
struct OPENFILENAMEA
{
uint lStructSize;
void* hwndOwner;
void* hInstance;
void* lpstrFilter;
void* lpstrCustomFilter;
uint nMaxCustFilter;
uint nFilterIndex;
void* lpstrFile;
uint nMaxFile;
void* lpstrFileTitle;
uint nMaxFileTitle;
void* lpstrInitialDir;
void* lpstrTitle;
uint Flags;
ushort nFileOffset;
ushort nFileExtension;
void* lpstrDefExt;
ptrdiff_t lCustData;
void* lpfnHook;
void* lpTemplateName;
void* pvReserved;
uint dwReserved;
uint FlagsEx;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; OPENFILENAMEA サイズ: 88 バイト(x86)
dim st, 22 ; 4byte整数×22(構造体サイズ 88 / 4 切り上げ)
; lStructSize : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; hwndOwner : HWND (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; hInstance : HINSTANCE (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; lpstrFilter : LPSTR (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; lpstrCustomFilter : LPSTR (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; nMaxCustFilter : DWORD (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; nFilterIndex : DWORD (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; lpstrFile : LPSTR (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; nMaxFile : DWORD (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; lpstrFileTitle : LPSTR (+36, 4byte) st.9 = 値 / 値 = st.9 (lpoke/lpeek も可)
; nMaxFileTitle : DWORD (+40, 4byte) st.10 = 値 / 値 = st.10 (lpoke/lpeek も可)
; lpstrInitialDir : LPSTR (+44, 4byte) st.11 = 値 / 値 = st.11 (lpoke/lpeek も可)
; lpstrTitle : LPSTR (+48, 4byte) st.12 = 値 / 値 = st.12 (lpoke/lpeek も可)
; Flags : OPEN_FILENAME_FLAGS (+52, 4byte) st.13 = 値 / 値 = st.13 (lpoke/lpeek も可)
; nFileOffset : WORD (+56, 2byte) wpoke st,56,値 / 値 = wpeek(st,56)
; nFileExtension : WORD (+58, 2byte) wpoke st,58,値 / 値 = wpeek(st,58)
; lpstrDefExt : LPSTR (+60, 4byte) st.15 = 値 / 値 = st.15 (lpoke/lpeek も可)
; lCustData : LPARAM (+64, 4byte) st.16 = 値 / 値 = st.16 (lpoke/lpeek も可)
; lpfnHook : LPOFNHOOKPROC (+68, 4byte) st.17 = 値 / 値 = st.17 (lpoke/lpeek も可)
; lpTemplateName : LPSTR (+72, 4byte) st.18 = 値 / 値 = st.18 (lpoke/lpeek も可)
; pvReserved : void* (+76, 4byte) st.19 = 値 / 値 = st.19 (lpoke/lpeek も可)
; dwReserved : DWORD (+80, 4byte) st.20 = 値 / 値 = st.20 (lpoke/lpeek も可)
; FlagsEx : OPEN_FILENAME_FLAGS_EX (+84, 4byte) st.21 = 値 / 値 = st.21 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; OPENFILENAMEA サイズ: 140 バイト(x64)
dim st, 35 ; 4byte整数×35(構造体サイズ 140 / 4 切り上げ)
; lStructSize : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; hwndOwner : HWND (+4, 8byte) qpoke st,4,値 / qpeek(st,4) ※IronHSPのみ。3.7/3.8は lpoke st,4,下位 : lpoke st,8,上位
; hInstance : HINSTANCE (+12, 8byte) qpoke st,12,値 / qpeek(st,12) ※IronHSPのみ。3.7/3.8は lpoke st,12,下位 : lpoke st,16,上位
; lpstrFilter : LPSTR (+20, 8byte) qpoke st,20,値 / qpeek(st,20) ※IronHSPのみ。3.7/3.8は lpoke st,20,下位 : lpoke st,24,上位
; lpstrCustomFilter : LPSTR (+28, 8byte) qpoke st,28,値 / qpeek(st,28) ※IronHSPのみ。3.7/3.8は lpoke st,28,下位 : lpoke st,32,上位
; nMaxCustFilter : DWORD (+36, 4byte) st.9 = 値 / 値 = st.9 (lpoke/lpeek も可)
; nFilterIndex : DWORD (+40, 4byte) st.10 = 値 / 値 = st.10 (lpoke/lpeek も可)
; lpstrFile : LPSTR (+44, 8byte) qpoke st,44,値 / qpeek(st,44) ※IronHSPのみ。3.7/3.8は lpoke st,44,下位 : lpoke st,48,上位
; nMaxFile : DWORD (+52, 4byte) st.13 = 値 / 値 = st.13 (lpoke/lpeek も可)
; lpstrFileTitle : LPSTR (+56, 8byte) qpoke st,56,値 / qpeek(st,56) ※IronHSPのみ。3.7/3.8は lpoke st,56,下位 : lpoke st,60,上位
; nMaxFileTitle : DWORD (+64, 4byte) st.16 = 値 / 値 = st.16 (lpoke/lpeek も可)
; lpstrInitialDir : LPSTR (+68, 8byte) qpoke st,68,値 / qpeek(st,68) ※IronHSPのみ。3.7/3.8は lpoke st,68,下位 : lpoke st,72,上位
; lpstrTitle : LPSTR (+76, 8byte) qpoke st,76,値 / qpeek(st,76) ※IronHSPのみ。3.7/3.8は lpoke st,76,下位 : lpoke st,80,上位
; Flags : OPEN_FILENAME_FLAGS (+84, 4byte) st.21 = 値 / 値 = st.21 (lpoke/lpeek も可)
; nFileOffset : WORD (+88, 2byte) wpoke st,88,値 / 値 = wpeek(st,88)
; nFileExtension : WORD (+90, 2byte) wpoke st,90,値 / 値 = wpeek(st,90)
; lpstrDefExt : LPSTR (+92, 8byte) qpoke st,92,値 / qpeek(st,92) ※IronHSPのみ。3.7/3.8は lpoke st,92,下位 : lpoke st,96,上位
; lCustData : LPARAM (+100, 8byte) qpoke st,100,値 / qpeek(st,100) ※IronHSPのみ。3.7/3.8は lpoke st,100,下位 : lpoke st,104,上位
; lpfnHook : LPOFNHOOKPROC (+108, 8byte) qpoke st,108,値 / qpeek(st,108) ※IronHSPのみ。3.7/3.8は lpoke st,108,下位 : lpoke st,112,上位
; lpTemplateName : LPSTR (+116, 8byte) qpoke st,116,値 / qpeek(st,116) ※IronHSPのみ。3.7/3.8は lpoke st,116,下位 : lpoke st,120,上位
; pvReserved : void* (+124, 8byte) qpoke st,124,値 / qpeek(st,124) ※IronHSPのみ。3.7/3.8は lpoke st,124,下位 : lpoke st,128,上位
; dwReserved : DWORD (+132, 4byte) st.33 = 値 / 値 = st.33 (lpoke/lpeek も可)
; FlagsEx : OPEN_FILENAME_FLAGS_EX (+136, 4byte) st.34 = 値 / 値 = st.34 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global OPENFILENAMEA, pack=1
#field int lStructSize
#field intptr hwndOwner
#field intptr hInstance
#field intptr lpstrFilter
#field intptr lpstrCustomFilter
#field int nMaxCustFilter
#field int nFilterIndex
#field intptr lpstrFile
#field int nMaxFile
#field intptr lpstrFileTitle
#field int nMaxFileTitle
#field intptr lpstrInitialDir
#field intptr lpstrTitle
#field int Flags
#field short nFileOffset
#field short nFileExtension
#field intptr lpstrDefExt
#field intptr lCustData
#field intptr lpfnHook
#field intptr lpTemplateName
#field intptr pvReserved
#field int dwReserved
#field int FlagsEx
#endstruct
stdim st, OPENFILENAMEA ; NSTRUCT 変数を確保
st->lStructSize = 100
mes "lStructSize=" + st->lStructSize