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

MFRegisterLocalByteStreamHandler

関数
拡張子やMIME型に対しバイトストリームハンドラーを登録する。
DLLMFPlat.dll呼出規約winapi対応OSwindows8.0

シグネチャ

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

HRESULT MFRegisterLocalByteStreamHandler(
    LPCWSTR szFileExtension,
    LPCWSTR szMimeType,
    IMFActivate* pActivate
);

パラメーター

名前方向
szFileExtensionLPCWSTRin
szMimeTypeLPCWSTRin
pActivateIMFActivate*in

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT MFRegisterLocalByteStreamHandler(
    LPCWSTR szFileExtension,
    LPCWSTR szMimeType,
    IMFActivate* pActivate
);
[DllImport("MFPlat.dll", ExactSpelling = true)]
static extern int MFRegisterLocalByteStreamHandler(
    [MarshalAs(UnmanagedType.LPWStr)] string szFileExtension,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string szMimeType,   // LPCWSTR
    IntPtr pActivate   // IMFActivate*
);
<DllImport("MFPlat.dll", ExactSpelling:=True)>
Public Shared Function MFRegisterLocalByteStreamHandler(
    <MarshalAs(UnmanagedType.LPWStr)> szFileExtension As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> szMimeType As String,   ' LPCWSTR
    pActivate As IntPtr   ' IMFActivate*
) As Integer
End Function
' szFileExtension : LPCWSTR
' szMimeType : LPCWSTR
' pActivate : IMFActivate*
Declare PtrSafe Function MFRegisterLocalByteStreamHandler Lib "mfplat" ( _
    ByVal szFileExtension As LongPtr, _
    ByVal szMimeType As LongPtr, _
    ByVal pActivate As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

MFRegisterLocalByteStreamHandler = ctypes.windll.mfplat.MFRegisterLocalByteStreamHandler
MFRegisterLocalByteStreamHandler.restype = ctypes.c_int
MFRegisterLocalByteStreamHandler.argtypes = [
    wintypes.LPCWSTR,  # szFileExtension : LPCWSTR
    wintypes.LPCWSTR,  # szMimeType : LPCWSTR
    ctypes.c_void_p,  # pActivate : IMFActivate*
]
require 'fiddle'
require 'fiddle/import'

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

var (
	mfplat = windows.NewLazySystemDLL("MFPlat.dll")
	procMFRegisterLocalByteStreamHandler = mfplat.NewProc("MFRegisterLocalByteStreamHandler")
)

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