ホーム › Web.InternetExplorer › IEShowOpenFileDialog
IEShowOpenFileDialog
関数IE保護モードでファイルを開くダイアログを表示する。
シグネチャ
// Ieframe.dll
#include <windows.h>
HRESULT IEShowOpenFileDialog(
HWND hwnd,
LPWSTR lpwstrFileName,
DWORD cchMaxFileName,
LPCWSTR lpwstrInitialDir, // optional
LPCWSTR lpwstrFilter, // optional
LPCWSTR lpwstrDefExt, // optional
DWORD dwFilterIndex,
DWORD dwFlags,
HANDLE* phFile
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hwnd | HWND | in | ダイアログの親ウィンドウのハンドル。 |
| lpwstrFileName | LPWSTR | inout | 初期ファイル名を渡し、選択結果を受け取るバッファへのポインタ。 |
| cchMaxFileName | DWORD | in | lpwstrFileNameバッファに格納できる最大文字数。 |
| lpwstrInitialDir | LPCWSTR | inoptional | 初期表示するディレクトリのパス。NULL可。 |
| lpwstrFilter | LPCWSTR | inoptional | ファイルタイプフィルタ文字列(NULL区切り)。 |
| lpwstrDefExt | LPCWSTR | inoptional | 拡張子未指定時に付加する既定の拡張子。NULL可。 |
| dwFilterIndex | DWORD | in | 初期選択するフィルタの1始まりインデックス。 |
| dwFlags | DWORD | in | ダイアログの動作を制御するフラグ。 |
| phFile | HANDLE* | out | 開いたファイルのハンドルを受け取るポインタ。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// Ieframe.dll
#include <windows.h>
HRESULT IEShowOpenFileDialog(
HWND hwnd,
LPWSTR lpwstrFileName,
DWORD cchMaxFileName,
LPCWSTR lpwstrInitialDir, // optional
LPCWSTR lpwstrFilter, // optional
LPCWSTR lpwstrDefExt, // optional
DWORD dwFilterIndex,
DWORD dwFlags,
HANDLE* phFile
);[DllImport("Ieframe.dll", ExactSpelling = true)]
static extern int IEShowOpenFileDialog(
IntPtr hwnd, // HWND
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpwstrFileName, // LPWSTR in/out
uint cchMaxFileName, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string lpwstrInitialDir, // LPCWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string lpwstrFilter, // LPCWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string lpwstrDefExt, // LPCWSTR optional
uint dwFilterIndex, // DWORD
uint dwFlags, // DWORD
IntPtr phFile // HANDLE* out
);<DllImport("Ieframe.dll", ExactSpelling:=True)>
Public Shared Function IEShowOpenFileDialog(
hwnd As IntPtr, ' HWND
<MarshalAs(UnmanagedType.LPWStr)> lpwstrFileName As System.Text.StringBuilder, ' LPWSTR in/out
cchMaxFileName As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> lpwstrInitialDir As String, ' LPCWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> lpwstrFilter As String, ' LPCWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> lpwstrDefExt As String, ' LPCWSTR optional
dwFilterIndex As UInteger, ' DWORD
dwFlags As UInteger, ' DWORD
phFile As IntPtr ' HANDLE* out
) As Integer
End Function' hwnd : HWND
' lpwstrFileName : LPWSTR in/out
' cchMaxFileName : DWORD
' lpwstrInitialDir : LPCWSTR optional
' lpwstrFilter : LPCWSTR optional
' lpwstrDefExt : LPCWSTR optional
' dwFilterIndex : DWORD
' dwFlags : DWORD
' phFile : HANDLE* out
Declare PtrSafe Function IEShowOpenFileDialog Lib "ieframe" ( _
ByVal hwnd As LongPtr, _
ByVal lpwstrFileName As LongPtr, _
ByVal cchMaxFileName As Long, _
ByVal lpwstrInitialDir As LongPtr, _
ByVal lpwstrFilter As LongPtr, _
ByVal lpwstrDefExt As LongPtr, _
ByVal dwFilterIndex As Long, _
ByVal dwFlags As Long, _
ByVal phFile As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
IEShowOpenFileDialog = ctypes.windll.ieframe.IEShowOpenFileDialog
IEShowOpenFileDialog.restype = ctypes.c_int
IEShowOpenFileDialog.argtypes = [
wintypes.HANDLE, # hwnd : HWND
wintypes.LPWSTR, # lpwstrFileName : LPWSTR in/out
wintypes.DWORD, # cchMaxFileName : DWORD
wintypes.LPCWSTR, # lpwstrInitialDir : LPCWSTR optional
wintypes.LPCWSTR, # lpwstrFilter : LPCWSTR optional
wintypes.LPCWSTR, # lpwstrDefExt : LPCWSTR optional
wintypes.DWORD, # dwFilterIndex : DWORD
wintypes.DWORD, # dwFlags : DWORD
ctypes.c_void_p, # phFile : HANDLE* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('Ieframe.dll')
IEShowOpenFileDialog = Fiddle::Function.new(
lib['IEShowOpenFileDialog'],
[
Fiddle::TYPE_VOIDP, # hwnd : HWND
Fiddle::TYPE_VOIDP, # lpwstrFileName : LPWSTR in/out
-Fiddle::TYPE_INT, # cchMaxFileName : DWORD
Fiddle::TYPE_VOIDP, # lpwstrInitialDir : LPCWSTR optional
Fiddle::TYPE_VOIDP, # lpwstrFilter : LPCWSTR optional
Fiddle::TYPE_VOIDP, # lpwstrDefExt : LPCWSTR optional
-Fiddle::TYPE_INT, # dwFilterIndex : DWORD
-Fiddle::TYPE_INT, # dwFlags : DWORD
Fiddle::TYPE_VOIDP, # phFile : HANDLE* out
],
Fiddle::TYPE_INT)#[link(name = "ieframe")]
extern "system" {
fn IEShowOpenFileDialog(
hwnd: *mut core::ffi::c_void, // HWND
lpwstrFileName: *mut u16, // LPWSTR in/out
cchMaxFileName: u32, // DWORD
lpwstrInitialDir: *const u16, // LPCWSTR optional
lpwstrFilter: *const u16, // LPCWSTR optional
lpwstrDefExt: *const u16, // LPCWSTR optional
dwFilterIndex: u32, // DWORD
dwFlags: u32, // DWORD
phFile: *mut *mut core::ffi::c_void // HANDLE* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("Ieframe.dll")]
public static extern int IEShowOpenFileDialog(IntPtr hwnd, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpwstrFileName, uint cchMaxFileName, [MarshalAs(UnmanagedType.LPWStr)] string lpwstrInitialDir, [MarshalAs(UnmanagedType.LPWStr)] string lpwstrFilter, [MarshalAs(UnmanagedType.LPWStr)] string lpwstrDefExt, uint dwFilterIndex, uint dwFlags, IntPtr phFile);
"@
$api = Add-Type -MemberDefinition $sig -Name 'Ieframe_IEShowOpenFileDialog' -Namespace Win32 -PassThru
# $api::IEShowOpenFileDialog(hwnd, lpwstrFileName, cchMaxFileName, lpwstrInitialDir, lpwstrFilter, lpwstrDefExt, dwFilterIndex, dwFlags, phFile)#uselib "Ieframe.dll"
#func global IEShowOpenFileDialog "IEShowOpenFileDialog" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; IEShowOpenFileDialog hwnd, varptr(lpwstrFileName), cchMaxFileName, lpwstrInitialDir, lpwstrFilter, lpwstrDefExt, dwFilterIndex, dwFlags, phFile ; 戻り値は stat
; hwnd : HWND -> "sptr"
; lpwstrFileName : LPWSTR in/out -> "sptr"
; cchMaxFileName : DWORD -> "sptr"
; lpwstrInitialDir : LPCWSTR optional -> "sptr"
; lpwstrFilter : LPCWSTR optional -> "sptr"
; lpwstrDefExt : LPCWSTR optional -> "sptr"
; dwFilterIndex : DWORD -> "sptr"
; dwFlags : DWORD -> "sptr"
; phFile : HANDLE* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "Ieframe.dll" #cfunc global IEShowOpenFileDialog "IEShowOpenFileDialog" sptr, var, int, wstr, wstr, wstr, int, int, sptr ; res = IEShowOpenFileDialog(hwnd, lpwstrFileName, cchMaxFileName, lpwstrInitialDir, lpwstrFilter, lpwstrDefExt, dwFilterIndex, dwFlags, phFile) ; hwnd : HWND -> "sptr" ; lpwstrFileName : LPWSTR in/out -> "var" ; cchMaxFileName : DWORD -> "int" ; lpwstrInitialDir : LPCWSTR optional -> "wstr" ; lpwstrFilter : LPCWSTR optional -> "wstr" ; lpwstrDefExt : LPCWSTR optional -> "wstr" ; dwFilterIndex : DWORD -> "int" ; dwFlags : DWORD -> "int" ; phFile : HANDLE* out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "Ieframe.dll" #cfunc global IEShowOpenFileDialog "IEShowOpenFileDialog" sptr, sptr, int, wstr, wstr, wstr, int, int, sptr ; res = IEShowOpenFileDialog(hwnd, varptr(lpwstrFileName), cchMaxFileName, lpwstrInitialDir, lpwstrFilter, lpwstrDefExt, dwFilterIndex, dwFlags, phFile) ; hwnd : HWND -> "sptr" ; lpwstrFileName : LPWSTR in/out -> "sptr" ; cchMaxFileName : DWORD -> "int" ; lpwstrInitialDir : LPCWSTR optional -> "wstr" ; lpwstrFilter : LPCWSTR optional -> "wstr" ; lpwstrDefExt : LPCWSTR optional -> "wstr" ; dwFilterIndex : DWORD -> "int" ; dwFlags : DWORD -> "int" ; phFile : HANDLE* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT IEShowOpenFileDialog(HWND hwnd, LPWSTR lpwstrFileName, DWORD cchMaxFileName, LPCWSTR lpwstrInitialDir, LPCWSTR lpwstrFilter, LPCWSTR lpwstrDefExt, DWORD dwFilterIndex, DWORD dwFlags, HANDLE* phFile) #uselib "Ieframe.dll" #cfunc global IEShowOpenFileDialog "IEShowOpenFileDialog" intptr, var, int, wstr, wstr, wstr, int, int, intptr ; res = IEShowOpenFileDialog(hwnd, lpwstrFileName, cchMaxFileName, lpwstrInitialDir, lpwstrFilter, lpwstrDefExt, dwFilterIndex, dwFlags, phFile) ; hwnd : HWND -> "intptr" ; lpwstrFileName : LPWSTR in/out -> "var" ; cchMaxFileName : DWORD -> "int" ; lpwstrInitialDir : LPCWSTR optional -> "wstr" ; lpwstrFilter : LPCWSTR optional -> "wstr" ; lpwstrDefExt : LPCWSTR optional -> "wstr" ; dwFilterIndex : DWORD -> "int" ; dwFlags : DWORD -> "int" ; phFile : HANDLE* out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT IEShowOpenFileDialog(HWND hwnd, LPWSTR lpwstrFileName, DWORD cchMaxFileName, LPCWSTR lpwstrInitialDir, LPCWSTR lpwstrFilter, LPCWSTR lpwstrDefExt, DWORD dwFilterIndex, DWORD dwFlags, HANDLE* phFile) #uselib "Ieframe.dll" #cfunc global IEShowOpenFileDialog "IEShowOpenFileDialog" intptr, intptr, int, wstr, wstr, wstr, int, int, intptr ; res = IEShowOpenFileDialog(hwnd, varptr(lpwstrFileName), cchMaxFileName, lpwstrInitialDir, lpwstrFilter, lpwstrDefExt, dwFilterIndex, dwFlags, phFile) ; hwnd : HWND -> "intptr" ; lpwstrFileName : LPWSTR in/out -> "intptr" ; cchMaxFileName : DWORD -> "int" ; lpwstrInitialDir : LPCWSTR optional -> "wstr" ; lpwstrFilter : LPCWSTR optional -> "wstr" ; lpwstrDefExt : LPCWSTR optional -> "wstr" ; dwFilterIndex : DWORD -> "int" ; dwFlags : DWORD -> "int" ; phFile : HANDLE* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ieframe = windows.NewLazySystemDLL("Ieframe.dll")
procIEShowOpenFileDialog = ieframe.NewProc("IEShowOpenFileDialog")
)
// hwnd (HWND), lpwstrFileName (LPWSTR in/out), cchMaxFileName (DWORD), lpwstrInitialDir (LPCWSTR optional), lpwstrFilter (LPCWSTR optional), lpwstrDefExt (LPCWSTR optional), dwFilterIndex (DWORD), dwFlags (DWORD), phFile (HANDLE* out)
r1, _, err := procIEShowOpenFileDialog.Call(
uintptr(hwnd),
uintptr(lpwstrFileName),
uintptr(cchMaxFileName),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpwstrInitialDir))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpwstrFilter))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpwstrDefExt))),
uintptr(dwFilterIndex),
uintptr(dwFlags),
uintptr(phFile),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction IEShowOpenFileDialog(
hwnd: THandle; // HWND
lpwstrFileName: PWideChar; // LPWSTR in/out
cchMaxFileName: DWORD; // DWORD
lpwstrInitialDir: PWideChar; // LPCWSTR optional
lpwstrFilter: PWideChar; // LPCWSTR optional
lpwstrDefExt: PWideChar; // LPCWSTR optional
dwFilterIndex: DWORD; // DWORD
dwFlags: DWORD; // DWORD
phFile: Pointer // HANDLE* out
): Integer; stdcall;
external 'Ieframe.dll' name 'IEShowOpenFileDialog';result := DllCall("Ieframe\IEShowOpenFileDialog"
, "Ptr", hwnd ; HWND
, "Ptr", lpwstrFileName ; LPWSTR in/out
, "UInt", cchMaxFileName ; DWORD
, "WStr", lpwstrInitialDir ; LPCWSTR optional
, "WStr", lpwstrFilter ; LPCWSTR optional
, "WStr", lpwstrDefExt ; LPCWSTR optional
, "UInt", dwFilterIndex ; DWORD
, "UInt", dwFlags ; DWORD
, "Ptr", phFile ; HANDLE* out
, "Int") ; return: HRESULT●IEShowOpenFileDialog(hwnd, lpwstrFileName, cchMaxFileName, lpwstrInitialDir, lpwstrFilter, lpwstrDefExt, dwFilterIndex, dwFlags, phFile) = DLL("Ieframe.dll", "int IEShowOpenFileDialog(void*, char*, dword, char*, char*, char*, dword, dword, void*)")
# 呼び出し: IEShowOpenFileDialog(hwnd, lpwstrFileName, cchMaxFileName, lpwstrInitialDir, lpwstrFilter, lpwstrDefExt, dwFilterIndex, dwFlags, phFile)
# hwnd : HWND -> "void*"
# lpwstrFileName : LPWSTR in/out -> "char*"
# cchMaxFileName : DWORD -> "dword"
# lpwstrInitialDir : LPCWSTR optional -> "char*"
# lpwstrFilter : LPCWSTR optional -> "char*"
# lpwstrDefExt : LPCWSTR optional -> "char*"
# dwFilterIndex : DWORD -> "dword"
# dwFlags : DWORD -> "dword"
# phFile : HANDLE* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。