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

AVIFileOpenW

関数
AVIファイルを開いてインターフェイスを取得する(Unicode版)。
DLLAVIFIL32.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// AVIFIL32.dll  (Unicode / -W)
#include <windows.h>

HRESULT AVIFileOpenW(
    IAVIFile** ppfile,
    LPCWSTR szFile,
    DWORD uMode,
    GUID* lpHandler   // optional
);

パラメーター

名前方向
ppfileIAVIFile**out
szFileLPCWSTRin
uModeDWORDin
lpHandlerGUID*inoptional

戻り値の型: HRESULT

各言語での呼び出し定義

// AVIFIL32.dll  (Unicode / -W)
#include <windows.h>

HRESULT AVIFileOpenW(
    IAVIFile** ppfile,
    LPCWSTR szFile,
    DWORD uMode,
    GUID* lpHandler   // optional
);
[DllImport("AVIFIL32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int AVIFileOpenW(
    IntPtr ppfile,   // IAVIFile** out
    [MarshalAs(UnmanagedType.LPWStr)] string szFile,   // LPCWSTR
    uint uMode,   // DWORD
    IntPtr lpHandler   // GUID* optional
);
<DllImport("AVIFIL32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function AVIFileOpenW(
    ppfile As IntPtr,   ' IAVIFile** out
    <MarshalAs(UnmanagedType.LPWStr)> szFile As String,   ' LPCWSTR
    uMode As UInteger,   ' DWORD
    lpHandler As IntPtr   ' GUID* optional
) As Integer
End Function
' ppfile : IAVIFile** out
' szFile : LPCWSTR
' uMode : DWORD
' lpHandler : GUID* optional
Declare PtrSafe Function AVIFileOpenW Lib "avifil32" ( _
    ByVal ppfile As LongPtr, _
    ByVal szFile As LongPtr, _
    ByVal uMode As Long, _
    ByVal lpHandler As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

AVIFileOpenW = ctypes.windll.avifil32.AVIFileOpenW
AVIFileOpenW.restype = ctypes.c_int
AVIFileOpenW.argtypes = [
    ctypes.c_void_p,  # ppfile : IAVIFile** out
    wintypes.LPCWSTR,  # szFile : LPCWSTR
    wintypes.DWORD,  # uMode : DWORD
    ctypes.c_void_p,  # lpHandler : GUID* optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('AVIFIL32.dll')
AVIFileOpenW = Fiddle::Function.new(
  lib['AVIFileOpenW'],
  [
    Fiddle::TYPE_VOIDP,  # ppfile : IAVIFile** out
    Fiddle::TYPE_VOIDP,  # szFile : LPCWSTR
    -Fiddle::TYPE_INT,  # uMode : DWORD
    Fiddle::TYPE_VOIDP,  # lpHandler : GUID* optional
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "avifil32")]
extern "system" {
    fn AVIFileOpenW(
        ppfile: *mut *mut core::ffi::c_void,  // IAVIFile** out
        szFile: *const u16,  // LPCWSTR
        uMode: u32,  // DWORD
        lpHandler: *mut GUID  // GUID* optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("AVIFIL32.dll", CharSet = CharSet.Unicode)]
public static extern int AVIFileOpenW(IntPtr ppfile, [MarshalAs(UnmanagedType.LPWStr)] string szFile, uint uMode, IntPtr lpHandler);
"@
$api = Add-Type -MemberDefinition $sig -Name 'AVIFIL32_AVIFileOpenW' -Namespace Win32 -PassThru
# $api::AVIFileOpenW(ppfile, szFile, uMode, lpHandler)
#uselib "AVIFIL32.dll"
#func global AVIFileOpenW "AVIFileOpenW" wptr, wptr, wptr, wptr
; AVIFileOpenW ppfile, szFile, uMode, varptr(lpHandler)   ; 戻り値は stat
; ppfile : IAVIFile** out -> "wptr"
; szFile : LPCWSTR -> "wptr"
; uMode : DWORD -> "wptr"
; lpHandler : GUID* optional -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "AVIFIL32.dll"
#cfunc global AVIFileOpenW "AVIFileOpenW" sptr, wstr, int, var
; res = AVIFileOpenW(ppfile, szFile, uMode, lpHandler)
; ppfile : IAVIFile** out -> "sptr"
; szFile : LPCWSTR -> "wstr"
; uMode : DWORD -> "int"
; lpHandler : GUID* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT AVIFileOpenW(IAVIFile** ppfile, LPCWSTR szFile, DWORD uMode, GUID* lpHandler)
#uselib "AVIFIL32.dll"
#cfunc global AVIFileOpenW "AVIFileOpenW" intptr, wstr, int, var
; res = AVIFileOpenW(ppfile, szFile, uMode, lpHandler)
; ppfile : IAVIFile** out -> "intptr"
; szFile : LPCWSTR -> "wstr"
; uMode : DWORD -> "int"
; lpHandler : GUID* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	avifil32 = windows.NewLazySystemDLL("AVIFIL32.dll")
	procAVIFileOpenW = avifil32.NewProc("AVIFileOpenW")
)

// ppfile (IAVIFile** out), szFile (LPCWSTR), uMode (DWORD), lpHandler (GUID* optional)
r1, _, err := procAVIFileOpenW.Call(
	uintptr(ppfile),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szFile))),
	uintptr(uMode),
	uintptr(lpHandler),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function AVIFileOpenW(
  ppfile: Pointer;   // IAVIFile** out
  szFile: PWideChar;   // LPCWSTR
  uMode: DWORD;   // DWORD
  lpHandler: PGUID   // GUID* optional
): Integer; stdcall;
  external 'AVIFIL32.dll' name 'AVIFileOpenW';
result := DllCall("AVIFIL32\AVIFileOpenW"
    , "Ptr", ppfile   ; IAVIFile** out
    , "WStr", szFile   ; LPCWSTR
    , "UInt", uMode   ; DWORD
    , "Ptr", lpHandler   ; GUID* optional
    , "Int")   ; return: HRESULT
●AVIFileOpenW(ppfile, szFile, uMode, lpHandler) = DLL("AVIFIL32.dll", "int AVIFileOpenW(void*, char*, dword, void*)")
# 呼び出し: AVIFileOpenW(ppfile, szFile, uMode, lpHandler)
# ppfile : IAVIFile** out -> "void*"
# szFile : LPCWSTR -> "char*"
# uMode : DWORD -> "dword"
# lpHandler : GUID* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。