Win32 API 日本語リファレンス
ホームMedia.Multimedia › GetOpenFileNamePreviewA

GetOpenFileNamePreviewA

関数
プレビュー付きのファイルを開くダイアログを表示する(ANSI版)。
DLLMSVFW32.dll文字セットANSI (-A)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// MSVFW32.dll  (ANSI / -A)
#include <windows.h>

BOOL GetOpenFileNamePreviewA(
    OPENFILENAMEA* lpofn
);

パラメーター

名前方向説明
lpofnOPENFILENAMEA*inoutダイアログ ボックスの初期化に使用する OPENFILENAME 構造体へのポインター。関数から戻ると、この構造体にはユーザーが選択したファイルに関する情報が格納されます。

戻り値の型: BOOL

公式ドキュメント

GetOpenFileNamePreview 関数は、[ファイルを開く] ダイアログ ボックスを使用してファイルを選択します。このダイアログ ボックスでは、現在指定されている AVI ファイルをプレビューすることもできます。この関数は、GetOpenFileName 関数の機能を拡張したものです。(ANSI)

戻り値

選択されたファイルのハンドルを返します。

解説(Remarks)

メモ

vfw.h ヘッダーは GetOpenFileNamePreview をエイリアスとして定義しており、UNICODE プリプロセッサ定数の定義に基づいて、この関数の ANSI 版または Unicode 版を自動的に選択します。エンコードに依存しないエイリアスの使用を、エンコードに依存しないわけではないコードと混在させると、不一致が生じ、コンパイル エラーや実行時エラーの原因となる場合があります。詳細については、関数プロトタイプの規則 を参照してください。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

// MSVFW32.dll  (ANSI / -A)
#include <windows.h>

BOOL GetOpenFileNamePreviewA(
    OPENFILENAMEA* lpofn
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("MSVFW32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern bool GetOpenFileNamePreviewA(
    IntPtr lpofn   // OPENFILENAMEA* in/out
);
<DllImport("MSVFW32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function GetOpenFileNamePreviewA(
    lpofn As IntPtr   ' OPENFILENAMEA* in/out
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
' lpofn : OPENFILENAMEA* in/out
Declare PtrSafe Function GetOpenFileNamePreviewA Lib "msvfw32" ( _
    ByVal lpofn As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetOpenFileNamePreviewA = ctypes.windll.msvfw32.GetOpenFileNamePreviewA
GetOpenFileNamePreviewA.restype = wintypes.BOOL
GetOpenFileNamePreviewA.argtypes = [
    ctypes.c_void_p,  # lpofn : OPENFILENAMEA* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('MSVFW32.dll')
GetOpenFileNamePreviewA = Fiddle::Function.new(
  lib['GetOpenFileNamePreviewA'],
  [
    Fiddle::TYPE_VOIDP,  # lpofn : OPENFILENAMEA* in/out
  ],
  Fiddle::TYPE_INT)
#[link(name = "msvfw32")]
extern "system" {
    fn GetOpenFileNamePreviewA(
        lpofn: *mut OPENFILENAMEA  // OPENFILENAMEA* in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("MSVFW32.dll", CharSet = CharSet.Ansi)]
public static extern bool GetOpenFileNamePreviewA(IntPtr lpofn);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MSVFW32_GetOpenFileNamePreviewA' -Namespace Win32 -PassThru
# $api::GetOpenFileNamePreviewA(lpofn)
#uselib "MSVFW32.dll"
#func global GetOpenFileNamePreviewA "GetOpenFileNamePreviewA" sptr
; GetOpenFileNamePreviewA varptr(lpofn)   ; 戻り値は stat
; lpofn : OPENFILENAMEA* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "MSVFW32.dll"
#cfunc global GetOpenFileNamePreviewA "GetOpenFileNamePreviewA" var
; res = GetOpenFileNamePreviewA(lpofn)
; lpofn : OPENFILENAMEA* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL GetOpenFileNamePreviewA(OPENFILENAMEA* lpofn)
#uselib "MSVFW32.dll"
#cfunc global GetOpenFileNamePreviewA "GetOpenFileNamePreviewA" var
; res = GetOpenFileNamePreviewA(lpofn)
; lpofn : OPENFILENAMEA* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	msvfw32 = windows.NewLazySystemDLL("MSVFW32.dll")
	procGetOpenFileNamePreviewA = msvfw32.NewProc("GetOpenFileNamePreviewA")
)

// lpofn (OPENFILENAMEA* in/out)
r1, _, err := procGetOpenFileNamePreviewA.Call(
	uintptr(lpofn),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function GetOpenFileNamePreviewA(
  lpofn: Pointer   // OPENFILENAMEA* in/out
): BOOL; stdcall;
  external 'MSVFW32.dll' name 'GetOpenFileNamePreviewA';
result := DllCall("MSVFW32\GetOpenFileNamePreviewA"
    , "Ptr", lpofn   ; OPENFILENAMEA* in/out
    , "Int")   ; return: BOOL
●GetOpenFileNamePreviewA(lpofn) = DLL("MSVFW32.dll", "bool GetOpenFileNamePreviewA(void*)")
# 呼び出し: GetOpenFileNamePreviewA(lpofn)
# lpofn : OPENFILENAMEA* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "msvfw32" fn GetOpenFileNamePreviewA(
    lpofn: [*c]OPENFILENAMEA // OPENFILENAMEA* in/out
) callconv(std.os.windows.WINAPI) i32;
proc GetOpenFileNamePreviewA(
    lpofn: ptr OPENFILENAMEA  # OPENFILENAMEA* in/out
): int32 {.importc: "GetOpenFileNamePreviewA", stdcall, dynlib: "MSVFW32.dll".}
pragma(lib, "msvfw32");
extern(Windows)
int GetOpenFileNamePreviewA(
    OPENFILENAMEA* lpofn   // OPENFILENAMEA* in/out
);
ccall((:GetOpenFileNamePreviewA, "MSVFW32.dll"), stdcall, Int32,
      (Ptr{OPENFILENAMEA},),
      lpofn)
# lpofn : OPENFILENAMEA* in/out -> Ptr{OPENFILENAMEA}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t GetOpenFileNamePreviewA(
    void* lpofn);
]]
local msvfw32 = ffi.load("msvfw32")
-- msvfw32.GetOpenFileNamePreviewA(lpofn)
-- lpofn : OPENFILENAMEA* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('MSVFW32.dll');
const GetOpenFileNamePreviewA = lib.func('__stdcall', 'GetOpenFileNamePreviewA', 'int32_t', ['void *']);
// GetOpenFileNamePreviewA(lpofn)
// lpofn : OPENFILENAMEA* in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("MSVFW32.dll", {
  GetOpenFileNamePreviewA: { parameters: ["pointer"], result: "i32" },
});
// lib.symbols.GetOpenFileNamePreviewA(lpofn)
// lpofn : OPENFILENAMEA* in/out -> "pointer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t GetOpenFileNamePreviewA(
    void* lpofn);
C, "MSVFW32.dll");
// $ffi->GetOpenFileNamePreviewA(lpofn);
// lpofn : OPENFILENAMEA* in/out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Msvfw32 extends StdCallLibrary {
    Msvfw32 INSTANCE = Native.load("msvfw32", Msvfw32.class, W32APIOptions.ASCII_OPTIONS);
    boolean GetOpenFileNamePreviewA(
        Pointer lpofn   // OPENFILENAMEA* in/out
    );
}
@[Link("msvfw32")]
lib LibMSVFW32
  fun GetOpenFileNamePreviewA = GetOpenFileNamePreviewA(
    lpofn : OPENFILENAMEA*   # OPENFILENAMEA* in/out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef GetOpenFileNamePreviewANative = Int32 Function(Pointer<Void>);
typedef GetOpenFileNamePreviewADart = int Function(Pointer<Void>);
final GetOpenFileNamePreviewA = DynamicLibrary.open('MSVFW32.dll')
    .lookupFunction<GetOpenFileNamePreviewANative, GetOpenFileNamePreviewADart>('GetOpenFileNamePreviewA');
// lpofn : OPENFILENAMEA* in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function GetOpenFileNamePreviewA(
  lpofn: Pointer   // OPENFILENAMEA* in/out
): BOOL; stdcall;
  external 'MSVFW32.dll' name 'GetOpenFileNamePreviewA';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "GetOpenFileNamePreviewA"
  c_GetOpenFileNamePreviewA :: Ptr () -> IO CInt
-- lpofn : OPENFILENAMEA* in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let getopenfilenamepreviewa =
  foreign "GetOpenFileNamePreviewA"
    ((ptr void) @-> returning int32_t)
(* lpofn : OPENFILENAMEA* in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library msvfw32 (t "MSVFW32.dll"))
(cffi:use-foreign-library msvfw32)

(cffi:defcfun ("GetOpenFileNamePreviewA" get-open-file-name-preview-a :convention :stdcall) :int32
  (lpofn :pointer))   ; OPENFILENAMEA* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $GetOpenFileNamePreviewA = Win32::API::More->new('MSVFW32',
    'BOOL GetOpenFileNamePreviewA(LPVOID lpofn)');
# my $ret = $GetOpenFileNamePreviewA->Call($lpofn);
# lpofn : OPENFILENAMEA* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

文字セット違い
使用する型