Win32 API 日本語リファレンス
ホームWeb.InternetExplorer › IEShowSaveFileDialog

IEShowSaveFileDialog

関数
IE保護モードで名前を付けて保存ダイアログを表示する。
DLLIeframe.dll呼出規約winapi

シグネチャ

// Ieframe.dll
#include <windows.h>

HRESULT IEShowSaveFileDialog(
    HWND hwnd,
    LPCWSTR lpwstrInitialFileName,
    LPCWSTR lpwstrInitialDir,   // optional
    LPCWSTR lpwstrFilter,   // optional
    LPCWSTR lpwstrDefExt,   // optional
    DWORD dwFilterIndex,
    DWORD dwFlags,
    LPWSTR* lppwstrDestinationFilePath,
    HANDLE* phState
);

パラメーター

名前方向説明
hwndHWNDinダイアログの親ウィンドウのハンドル。
lpwstrInitialFileNameLPCWSTRin初期表示するファイル名。
lpwstrInitialDirLPCWSTRinoptional初期表示するディレクトリのパス。NULL可。
lpwstrFilterLPCWSTRinoptionalファイルタイプフィルタ文字列(NULL区切り)。
lpwstrDefExtLPCWSTRinoptional拡張子未指定時に付加する既定の拡張子。NULL可。
dwFilterIndexDWORDin初期選択するフィルタの1始まりインデックス。
dwFlagsDWORDinダイアログの動作を制御するフラグ。
lppwstrDestinationFilePathLPWSTR*out選択された保存先ファイルパスを受け取る出力ポインタ。
phStateHANDLE*out後続の保存操作で使う状態ハンドルを受け取るポインタ。

戻り値の型: HRESULT

各言語での呼び出し定義

// Ieframe.dll
#include <windows.h>

HRESULT IEShowSaveFileDialog(
    HWND hwnd,
    LPCWSTR lpwstrInitialFileName,
    LPCWSTR lpwstrInitialDir,   // optional
    LPCWSTR lpwstrFilter,   // optional
    LPCWSTR lpwstrDefExt,   // optional
    DWORD dwFilterIndex,
    DWORD dwFlags,
    LPWSTR* lppwstrDestinationFilePath,
    HANDLE* phState
);
[DllImport("Ieframe.dll", ExactSpelling = true)]
static extern int IEShowSaveFileDialog(
    IntPtr hwnd,   // HWND
    [MarshalAs(UnmanagedType.LPWStr)] string lpwstrInitialFileName,   // LPCWSTR
    [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 lppwstrDestinationFilePath,   // LPWSTR* out
    IntPtr phState   // HANDLE* out
);
<DllImport("Ieframe.dll", ExactSpelling:=True)>
Public Shared Function IEShowSaveFileDialog(
    hwnd As IntPtr,   ' HWND
    <MarshalAs(UnmanagedType.LPWStr)> lpwstrInitialFileName As String,   ' LPCWSTR
    <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
    lppwstrDestinationFilePath As IntPtr,   ' LPWSTR* out
    phState As IntPtr   ' HANDLE* out
) As Integer
End Function
' hwnd : HWND
' lpwstrInitialFileName : LPCWSTR
' lpwstrInitialDir : LPCWSTR optional
' lpwstrFilter : LPCWSTR optional
' lpwstrDefExt : LPCWSTR optional
' dwFilterIndex : DWORD
' dwFlags : DWORD
' lppwstrDestinationFilePath : LPWSTR* out
' phState : HANDLE* out
Declare PtrSafe Function IEShowSaveFileDialog Lib "ieframe" ( _
    ByVal hwnd As LongPtr, _
    ByVal lpwstrInitialFileName As LongPtr, _
    ByVal lpwstrInitialDir As LongPtr, _
    ByVal lpwstrFilter As LongPtr, _
    ByVal lpwstrDefExt As LongPtr, _
    ByVal dwFilterIndex As Long, _
    ByVal dwFlags As Long, _
    ByVal lppwstrDestinationFilePath As LongPtr, _
    ByVal phState As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

IEShowSaveFileDialog = ctypes.windll.ieframe.IEShowSaveFileDialog
IEShowSaveFileDialog.restype = ctypes.c_int
IEShowSaveFileDialog.argtypes = [
    wintypes.HANDLE,  # hwnd : HWND
    wintypes.LPCWSTR,  # lpwstrInitialFileName : LPCWSTR
    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,  # lppwstrDestinationFilePath : LPWSTR* out
    ctypes.c_void_p,  # phState : HANDLE* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('Ieframe.dll')
IEShowSaveFileDialog = Fiddle::Function.new(
  lib['IEShowSaveFileDialog'],
  [
    Fiddle::TYPE_VOIDP,  # hwnd : HWND
    Fiddle::TYPE_VOIDP,  # lpwstrInitialFileName : LPCWSTR
    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,  # lppwstrDestinationFilePath : LPWSTR* out
    Fiddle::TYPE_VOIDP,  # phState : HANDLE* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "ieframe")]
extern "system" {
    fn IEShowSaveFileDialog(
        hwnd: *mut core::ffi::c_void,  // HWND
        lpwstrInitialFileName: *const u16,  // LPCWSTR
        lpwstrInitialDir: *const u16,  // LPCWSTR optional
        lpwstrFilter: *const u16,  // LPCWSTR optional
        lpwstrDefExt: *const u16,  // LPCWSTR optional
        dwFilterIndex: u32,  // DWORD
        dwFlags: u32,  // DWORD
        lppwstrDestinationFilePath: *mut *mut u16,  // LPWSTR* out
        phState: *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 IEShowSaveFileDialog(IntPtr hwnd, [MarshalAs(UnmanagedType.LPWStr)] string lpwstrInitialFileName, [MarshalAs(UnmanagedType.LPWStr)] string lpwstrInitialDir, [MarshalAs(UnmanagedType.LPWStr)] string lpwstrFilter, [MarshalAs(UnmanagedType.LPWStr)] string lpwstrDefExt, uint dwFilterIndex, uint dwFlags, IntPtr lppwstrDestinationFilePath, IntPtr phState);
"@
$api = Add-Type -MemberDefinition $sig -Name 'Ieframe_IEShowSaveFileDialog' -Namespace Win32 -PassThru
# $api::IEShowSaveFileDialog(hwnd, lpwstrInitialFileName, lpwstrInitialDir, lpwstrFilter, lpwstrDefExt, dwFilterIndex, dwFlags, lppwstrDestinationFilePath, phState)
#uselib "Ieframe.dll"
#func global IEShowSaveFileDialog "IEShowSaveFileDialog" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; IEShowSaveFileDialog hwnd, lpwstrInitialFileName, lpwstrInitialDir, lpwstrFilter, lpwstrDefExt, dwFilterIndex, dwFlags, varptr(lppwstrDestinationFilePath), phState   ; 戻り値は stat
; hwnd : HWND -> "sptr"
; lpwstrInitialFileName : LPCWSTR -> "sptr"
; lpwstrInitialDir : LPCWSTR optional -> "sptr"
; lpwstrFilter : LPCWSTR optional -> "sptr"
; lpwstrDefExt : LPCWSTR optional -> "sptr"
; dwFilterIndex : DWORD -> "sptr"
; dwFlags : DWORD -> "sptr"
; lppwstrDestinationFilePath : LPWSTR* out -> "sptr"
; phState : HANDLE* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "Ieframe.dll"
#cfunc global IEShowSaveFileDialog "IEShowSaveFileDialog" sptr, wstr, wstr, wstr, wstr, int, int, var, sptr
; res = IEShowSaveFileDialog(hwnd, lpwstrInitialFileName, lpwstrInitialDir, lpwstrFilter, lpwstrDefExt, dwFilterIndex, dwFlags, lppwstrDestinationFilePath, phState)
; hwnd : HWND -> "sptr"
; lpwstrInitialFileName : LPCWSTR -> "wstr"
; lpwstrInitialDir : LPCWSTR optional -> "wstr"
; lpwstrFilter : LPCWSTR optional -> "wstr"
; lpwstrDefExt : LPCWSTR optional -> "wstr"
; dwFilterIndex : DWORD -> "int"
; dwFlags : DWORD -> "int"
; lppwstrDestinationFilePath : LPWSTR* out -> "var"
; phState : HANDLE* out -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT IEShowSaveFileDialog(HWND hwnd, LPCWSTR lpwstrInitialFileName, LPCWSTR lpwstrInitialDir, LPCWSTR lpwstrFilter, LPCWSTR lpwstrDefExt, DWORD dwFilterIndex, DWORD dwFlags, LPWSTR* lppwstrDestinationFilePath, HANDLE* phState)
#uselib "Ieframe.dll"
#cfunc global IEShowSaveFileDialog "IEShowSaveFileDialog" intptr, wstr, wstr, wstr, wstr, int, int, var, intptr
; res = IEShowSaveFileDialog(hwnd, lpwstrInitialFileName, lpwstrInitialDir, lpwstrFilter, lpwstrDefExt, dwFilterIndex, dwFlags, lppwstrDestinationFilePath, phState)
; hwnd : HWND -> "intptr"
; lpwstrInitialFileName : LPCWSTR -> "wstr"
; lpwstrInitialDir : LPCWSTR optional -> "wstr"
; lpwstrFilter : LPCWSTR optional -> "wstr"
; lpwstrDefExt : LPCWSTR optional -> "wstr"
; dwFilterIndex : DWORD -> "int"
; dwFlags : DWORD -> "int"
; lppwstrDestinationFilePath : LPWSTR* out -> "var"
; phState : HANDLE* out -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	ieframe = windows.NewLazySystemDLL("Ieframe.dll")
	procIEShowSaveFileDialog = ieframe.NewProc("IEShowSaveFileDialog")
)

// hwnd (HWND), lpwstrInitialFileName (LPCWSTR), lpwstrInitialDir (LPCWSTR optional), lpwstrFilter (LPCWSTR optional), lpwstrDefExt (LPCWSTR optional), dwFilterIndex (DWORD), dwFlags (DWORD), lppwstrDestinationFilePath (LPWSTR* out), phState (HANDLE* out)
r1, _, err := procIEShowSaveFileDialog.Call(
	uintptr(hwnd),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpwstrInitialFileName))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpwstrInitialDir))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpwstrFilter))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpwstrDefExt))),
	uintptr(dwFilterIndex),
	uintptr(dwFlags),
	uintptr(lppwstrDestinationFilePath),
	uintptr(phState),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function IEShowSaveFileDialog(
  hwnd: THandle;   // HWND
  lpwstrInitialFileName: PWideChar;   // LPCWSTR
  lpwstrInitialDir: PWideChar;   // LPCWSTR optional
  lpwstrFilter: PWideChar;   // LPCWSTR optional
  lpwstrDefExt: PWideChar;   // LPCWSTR optional
  dwFilterIndex: DWORD;   // DWORD
  dwFlags: DWORD;   // DWORD
  lppwstrDestinationFilePath: PPWideChar;   // LPWSTR* out
  phState: Pointer   // HANDLE* out
): Integer; stdcall;
  external 'Ieframe.dll' name 'IEShowSaveFileDialog';
result := DllCall("Ieframe\IEShowSaveFileDialog"
    , "Ptr", hwnd   ; HWND
    , "WStr", lpwstrInitialFileName   ; LPCWSTR
    , "WStr", lpwstrInitialDir   ; LPCWSTR optional
    , "WStr", lpwstrFilter   ; LPCWSTR optional
    , "WStr", lpwstrDefExt   ; LPCWSTR optional
    , "UInt", dwFilterIndex   ; DWORD
    , "UInt", dwFlags   ; DWORD
    , "Ptr", lppwstrDestinationFilePath   ; LPWSTR* out
    , "Ptr", phState   ; HANDLE* out
    , "Int")   ; return: HRESULT
●IEShowSaveFileDialog(hwnd, lpwstrInitialFileName, lpwstrInitialDir, lpwstrFilter, lpwstrDefExt, dwFilterIndex, dwFlags, lppwstrDestinationFilePath, phState) = DLL("Ieframe.dll", "int IEShowSaveFileDialog(void*, char*, char*, char*, char*, dword, dword, void*, void*)")
# 呼び出し: IEShowSaveFileDialog(hwnd, lpwstrInitialFileName, lpwstrInitialDir, lpwstrFilter, lpwstrDefExt, dwFilterIndex, dwFlags, lppwstrDestinationFilePath, phState)
# hwnd : HWND -> "void*"
# lpwstrInitialFileName : LPCWSTR -> "char*"
# lpwstrInitialDir : LPCWSTR optional -> "char*"
# lpwstrFilter : LPCWSTR optional -> "char*"
# lpwstrDefExt : LPCWSTR optional -> "char*"
# dwFilterIndex : DWORD -> "dword"
# dwFlags : DWORD -> "dword"
# lppwstrDestinationFilePath : LPWSTR* out -> "void*"
# phState : HANDLE* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。