Win32 API 日本語リファレンス
ホームSystem.Com.Urlmon › FindMediaTypeClass

FindMediaTypeClass

関数
指定したメディア型に対応するクラスIDをバインドコンテキストから検索する。
DLLurlmon.dll呼出規約winapi

シグネチャ

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

HRESULT FindMediaTypeClass(
    IBindCtx* pBC,
    LPCSTR szType,
    GUID* pclsID,
    DWORD reserved
);

パラメーター

名前方向
pBCIBindCtx*in
szTypeLPCSTRin
pclsIDGUID*out
reservedDWORDin

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT FindMediaTypeClass(
    IBindCtx* pBC,
    LPCSTR szType,
    GUID* pclsID,
    DWORD reserved
);
[DllImport("urlmon.dll", ExactSpelling = true)]
static extern int FindMediaTypeClass(
    IntPtr pBC,   // IBindCtx*
    [MarshalAs(UnmanagedType.LPStr)] string szType,   // LPCSTR
    out Guid pclsID,   // GUID* out
    uint reserved   // DWORD
);
<DllImport("urlmon.dll", ExactSpelling:=True)>
Public Shared Function FindMediaTypeClass(
    pBC As IntPtr,   ' IBindCtx*
    <MarshalAs(UnmanagedType.LPStr)> szType As String,   ' LPCSTR
    <Out> ByRef pclsID As Guid,   ' GUID* out
    reserved As UInteger   ' DWORD
) As Integer
End Function
' pBC : IBindCtx*
' szType : LPCSTR
' pclsID : GUID* out
' reserved : DWORD
Declare PtrSafe Function FindMediaTypeClass Lib "urlmon" ( _
    ByVal pBC As LongPtr, _
    ByVal szType As String, _
    ByVal pclsID As LongPtr, _
    ByVal reserved As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

FindMediaTypeClass = ctypes.windll.urlmon.FindMediaTypeClass
FindMediaTypeClass.restype = ctypes.c_int
FindMediaTypeClass.argtypes = [
    ctypes.c_void_p,  # pBC : IBindCtx*
    wintypes.LPCSTR,  # szType : LPCSTR
    ctypes.c_void_p,  # pclsID : GUID* out
    wintypes.DWORD,  # reserved : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('urlmon.dll')
FindMediaTypeClass = Fiddle::Function.new(
  lib['FindMediaTypeClass'],
  [
    Fiddle::TYPE_VOIDP,  # pBC : IBindCtx*
    Fiddle::TYPE_VOIDP,  # szType : LPCSTR
    Fiddle::TYPE_VOIDP,  # pclsID : GUID* out
    -Fiddle::TYPE_INT,  # reserved : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "urlmon")]
extern "system" {
    fn FindMediaTypeClass(
        pBC: *mut core::ffi::c_void,  // IBindCtx*
        szType: *const u8,  // LPCSTR
        pclsID: *mut GUID,  // GUID* out
        reserved: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("urlmon.dll")]
public static extern int FindMediaTypeClass(IntPtr pBC, [MarshalAs(UnmanagedType.LPStr)] string szType, out Guid pclsID, uint reserved);
"@
$api = Add-Type -MemberDefinition $sig -Name 'urlmon_FindMediaTypeClass' -Namespace Win32 -PassThru
# $api::FindMediaTypeClass(pBC, szType, pclsID, reserved)
#uselib "urlmon.dll"
#func global FindMediaTypeClass "FindMediaTypeClass" sptr, sptr, sptr, sptr
; FindMediaTypeClass pBC, szType, varptr(pclsID), reserved   ; 戻り値は stat
; pBC : IBindCtx* -> "sptr"
; szType : LPCSTR -> "sptr"
; pclsID : GUID* out -> "sptr"
; reserved : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "urlmon.dll"
#cfunc global FindMediaTypeClass "FindMediaTypeClass" sptr, str, var, int
; res = FindMediaTypeClass(pBC, szType, pclsID, reserved)
; pBC : IBindCtx* -> "sptr"
; szType : LPCSTR -> "str"
; pclsID : GUID* out -> "var"
; reserved : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT FindMediaTypeClass(IBindCtx* pBC, LPCSTR szType, GUID* pclsID, DWORD reserved)
#uselib "urlmon.dll"
#cfunc global FindMediaTypeClass "FindMediaTypeClass" intptr, str, var, int
; res = FindMediaTypeClass(pBC, szType, pclsID, reserved)
; pBC : IBindCtx* -> "intptr"
; szType : LPCSTR -> "str"
; pclsID : GUID* out -> "var"
; reserved : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	urlmon = windows.NewLazySystemDLL("urlmon.dll")
	procFindMediaTypeClass = urlmon.NewProc("FindMediaTypeClass")
)

// pBC (IBindCtx*), szType (LPCSTR), pclsID (GUID* out), reserved (DWORD)
r1, _, err := procFindMediaTypeClass.Call(
	uintptr(pBC),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(szType))),
	uintptr(pclsID),
	uintptr(reserved),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function FindMediaTypeClass(
  pBC: Pointer;   // IBindCtx*
  szType: PAnsiChar;   // LPCSTR
  pclsID: PGUID;   // GUID* out
  reserved: DWORD   // DWORD
): Integer; stdcall;
  external 'urlmon.dll' name 'FindMediaTypeClass';
result := DllCall("urlmon\FindMediaTypeClass"
    , "Ptr", pBC   ; IBindCtx*
    , "AStr", szType   ; LPCSTR
    , "Ptr", pclsID   ; GUID* out
    , "UInt", reserved   ; DWORD
    , "Int")   ; return: HRESULT
●FindMediaTypeClass(pBC, szType, pclsID, reserved) = DLL("urlmon.dll", "int FindMediaTypeClass(void*, char*, void*, dword)")
# 呼び出し: FindMediaTypeClass(pBC, szType, pclsID, reserved)
# pBC : IBindCtx* -> "void*"
# szType : LPCSTR -> "char*"
# pclsID : GUID* out -> "void*"
# reserved : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。