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

MFCreateSinkWriterFromURL

関数
出力URLからメディアファイル書き込み用シンクライターを作成する。
DLLMFReadWrite.dll呼出規約winapi対応OSWindows 7 以降

シグネチャ

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

HRESULT MFCreateSinkWriterFromURL(
    LPCWSTR pwszOutputURL,   // optional
    IMFByteStream* pByteStream,   // optional
    IMFAttributes* pAttributes,   // optional
    IMFSinkWriter** ppSinkWriter
);

パラメーター

名前方向
pwszOutputURLLPCWSTRinoptional
pByteStreamIMFByteStream*inoptional
pAttributesIMFAttributes*inoptional
ppSinkWriterIMFSinkWriter**out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT MFCreateSinkWriterFromURL(
    LPCWSTR pwszOutputURL,   // optional
    IMFByteStream* pByteStream,   // optional
    IMFAttributes* pAttributes,   // optional
    IMFSinkWriter** ppSinkWriter
);
[DllImport("MFReadWrite.dll", ExactSpelling = true)]
static extern int MFCreateSinkWriterFromURL(
    [MarshalAs(UnmanagedType.LPWStr)] string pwszOutputURL,   // LPCWSTR optional
    IntPtr pByteStream,   // IMFByteStream* optional
    IntPtr pAttributes,   // IMFAttributes* optional
    IntPtr ppSinkWriter   // IMFSinkWriter** out
);
<DllImport("MFReadWrite.dll", ExactSpelling:=True)>
Public Shared Function MFCreateSinkWriterFromURL(
    <MarshalAs(UnmanagedType.LPWStr)> pwszOutputURL As String,   ' LPCWSTR optional
    pByteStream As IntPtr,   ' IMFByteStream* optional
    pAttributes As IntPtr,   ' IMFAttributes* optional
    ppSinkWriter As IntPtr   ' IMFSinkWriter** out
) As Integer
End Function
' pwszOutputURL : LPCWSTR optional
' pByteStream : IMFByteStream* optional
' pAttributes : IMFAttributes* optional
' ppSinkWriter : IMFSinkWriter** out
Declare PtrSafe Function MFCreateSinkWriterFromURL Lib "mfreadwrite" ( _
    ByVal pwszOutputURL As LongPtr, _
    ByVal pByteStream As LongPtr, _
    ByVal pAttributes As LongPtr, _
    ByVal ppSinkWriter As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

MFCreateSinkWriterFromURL = ctypes.windll.mfreadwrite.MFCreateSinkWriterFromURL
MFCreateSinkWriterFromURL.restype = ctypes.c_int
MFCreateSinkWriterFromURL.argtypes = [
    wintypes.LPCWSTR,  # pwszOutputURL : LPCWSTR optional
    ctypes.c_void_p,  # pByteStream : IMFByteStream* optional
    ctypes.c_void_p,  # pAttributes : IMFAttributes* optional
    ctypes.c_void_p,  # ppSinkWriter : IMFSinkWriter** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('MFReadWrite.dll')
MFCreateSinkWriterFromURL = Fiddle::Function.new(
  lib['MFCreateSinkWriterFromURL'],
  [
    Fiddle::TYPE_VOIDP,  # pwszOutputURL : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # pByteStream : IMFByteStream* optional
    Fiddle::TYPE_VOIDP,  # pAttributes : IMFAttributes* optional
    Fiddle::TYPE_VOIDP,  # ppSinkWriter : IMFSinkWriter** out
  ],
  Fiddle::TYPE_INT)
#[link(name = "mfreadwrite")]
extern "system" {
    fn MFCreateSinkWriterFromURL(
        pwszOutputURL: *const u16,  // LPCWSTR optional
        pByteStream: *mut core::ffi::c_void,  // IMFByteStream* optional
        pAttributes: *mut core::ffi::c_void,  // IMFAttributes* optional
        ppSinkWriter: *mut *mut core::ffi::c_void  // IMFSinkWriter** out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("MFReadWrite.dll")]
public static extern int MFCreateSinkWriterFromURL([MarshalAs(UnmanagedType.LPWStr)] string pwszOutputURL, IntPtr pByteStream, IntPtr pAttributes, IntPtr ppSinkWriter);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MFReadWrite_MFCreateSinkWriterFromURL' -Namespace Win32 -PassThru
# $api::MFCreateSinkWriterFromURL(pwszOutputURL, pByteStream, pAttributes, ppSinkWriter)
#uselib "MFReadWrite.dll"
#func global MFCreateSinkWriterFromURL "MFCreateSinkWriterFromURL" sptr, sptr, sptr, sptr
; MFCreateSinkWriterFromURL pwszOutputURL, pByteStream, pAttributes, ppSinkWriter   ; 戻り値は stat
; pwszOutputURL : LPCWSTR optional -> "sptr"
; pByteStream : IMFByteStream* optional -> "sptr"
; pAttributes : IMFAttributes* optional -> "sptr"
; ppSinkWriter : IMFSinkWriter** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "MFReadWrite.dll"
#cfunc global MFCreateSinkWriterFromURL "MFCreateSinkWriterFromURL" wstr, sptr, sptr, sptr
; res = MFCreateSinkWriterFromURL(pwszOutputURL, pByteStream, pAttributes, ppSinkWriter)
; pwszOutputURL : LPCWSTR optional -> "wstr"
; pByteStream : IMFByteStream* optional -> "sptr"
; pAttributes : IMFAttributes* optional -> "sptr"
; ppSinkWriter : IMFSinkWriter** out -> "sptr"
; HRESULT MFCreateSinkWriterFromURL(LPCWSTR pwszOutputURL, IMFByteStream* pByteStream, IMFAttributes* pAttributes, IMFSinkWriter** ppSinkWriter)
#uselib "MFReadWrite.dll"
#cfunc global MFCreateSinkWriterFromURL "MFCreateSinkWriterFromURL" wstr, intptr, intptr, intptr
; res = MFCreateSinkWriterFromURL(pwszOutputURL, pByteStream, pAttributes, ppSinkWriter)
; pwszOutputURL : LPCWSTR optional -> "wstr"
; pByteStream : IMFByteStream* optional -> "intptr"
; pAttributes : IMFAttributes* optional -> "intptr"
; ppSinkWriter : IMFSinkWriter** out -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	mfreadwrite = windows.NewLazySystemDLL("MFReadWrite.dll")
	procMFCreateSinkWriterFromURL = mfreadwrite.NewProc("MFCreateSinkWriterFromURL")
)

// pwszOutputURL (LPCWSTR optional), pByteStream (IMFByteStream* optional), pAttributes (IMFAttributes* optional), ppSinkWriter (IMFSinkWriter** out)
r1, _, err := procMFCreateSinkWriterFromURL.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwszOutputURL))),
	uintptr(pByteStream),
	uintptr(pAttributes),
	uintptr(ppSinkWriter),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function MFCreateSinkWriterFromURL(
  pwszOutputURL: PWideChar;   // LPCWSTR optional
  pByteStream: Pointer;   // IMFByteStream* optional
  pAttributes: Pointer;   // IMFAttributes* optional
  ppSinkWriter: Pointer   // IMFSinkWriter** out
): Integer; stdcall;
  external 'MFReadWrite.dll' name 'MFCreateSinkWriterFromURL';
result := DllCall("MFReadWrite\MFCreateSinkWriterFromURL"
    , "WStr", pwszOutputURL   ; LPCWSTR optional
    , "Ptr", pByteStream   ; IMFByteStream* optional
    , "Ptr", pAttributes   ; IMFAttributes* optional
    , "Ptr", ppSinkWriter   ; IMFSinkWriter** out
    , "Int")   ; return: HRESULT
●MFCreateSinkWriterFromURL(pwszOutputURL, pByteStream, pAttributes, ppSinkWriter) = DLL("MFReadWrite.dll", "int MFCreateSinkWriterFromURL(char*, void*, void*, void*)")
# 呼び出し: MFCreateSinkWriterFromURL(pwszOutputURL, pByteStream, pAttributes, ppSinkWriter)
# pwszOutputURL : LPCWSTR optional -> "char*"
# pByteStream : IMFByteStream* optional -> "void*"
# pAttributes : IMFAttributes* optional -> "void*"
# ppSinkWriter : IMFSinkWriter** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。