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

MFCreateSensorProfile

関数
プロファイル種別と制約からセンサープロファイルを生成する。
DLLMFSENSORGROUP.dll呼出規約winapi対応OSWindows 10 以降

シグネチャ

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

HRESULT MFCreateSensorProfile(
    const GUID* ProfileType,
    DWORD ProfileIndex,
    LPCWSTR Constraints,   // optional
    IMFSensorProfile** ppProfile
);

パラメーター

名前方向説明
ProfileTypeGUID*in作成するプロファイルの型。
ProfileIndexDWORDinプロファイルのインデックス。
ConstraintsLPCWSTRinoptionalプロファイルに設定する省略可能な制約。
ppProfileIMFSensorProfile**out成功した場合、センサープロファイルを格納する IMFSensorProfile へのダブルポインターを返します。

戻り値の型: HRESULT

公式ドキュメント

指定された型、インデックス、および省略可能な制約に基づいて、センサープロファイルを作成します。

戻り値

この関数は値を返しません。

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

各言語での呼び出し定義

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

HRESULT MFCreateSensorProfile(
    const GUID* ProfileType,
    DWORD ProfileIndex,
    LPCWSTR Constraints,   // optional
    IMFSensorProfile** ppProfile
);
[DllImport("MFSENSORGROUP.dll", ExactSpelling = true)]
static extern int MFCreateSensorProfile(
    ref Guid ProfileType,   // GUID*
    uint ProfileIndex,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] string Constraints,   // LPCWSTR optional
    IntPtr ppProfile   // IMFSensorProfile** out
);
<DllImport("MFSENSORGROUP.dll", ExactSpelling:=True)>
Public Shared Function MFCreateSensorProfile(
    ByRef ProfileType As Guid,   ' GUID*
    ProfileIndex As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> Constraints As String,   ' LPCWSTR optional
    ppProfile As IntPtr   ' IMFSensorProfile** out
) As Integer
End Function
' ProfileType : GUID*
' ProfileIndex : DWORD
' Constraints : LPCWSTR optional
' ppProfile : IMFSensorProfile** out
Declare PtrSafe Function MFCreateSensorProfile Lib "mfsensorgroup" ( _
    ByVal ProfileType As LongPtr, _
    ByVal ProfileIndex As Long, _
    ByVal Constraints As LongPtr, _
    ByVal ppProfile As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

MFCreateSensorProfile = ctypes.windll.mfsensorgroup.MFCreateSensorProfile
MFCreateSensorProfile.restype = ctypes.c_int
MFCreateSensorProfile.argtypes = [
    ctypes.c_void_p,  # ProfileType : GUID*
    wintypes.DWORD,  # ProfileIndex : DWORD
    wintypes.LPCWSTR,  # Constraints : LPCWSTR optional
    ctypes.c_void_p,  # ppProfile : IMFSensorProfile** out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	mfsensorgroup = windows.NewLazySystemDLL("MFSENSORGROUP.dll")
	procMFCreateSensorProfile = mfsensorgroup.NewProc("MFCreateSensorProfile")
)

// ProfileType (GUID*), ProfileIndex (DWORD), Constraints (LPCWSTR optional), ppProfile (IMFSensorProfile** out)
r1, _, err := procMFCreateSensorProfile.Call(
	uintptr(ProfileType),
	uintptr(ProfileIndex),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(Constraints))),
	uintptr(ppProfile),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function MFCreateSensorProfile(
  ProfileType: PGUID;   // GUID*
  ProfileIndex: DWORD;   // DWORD
  Constraints: PWideChar;   // LPCWSTR optional
  ppProfile: Pointer   // IMFSensorProfile** out
): Integer; stdcall;
  external 'MFSENSORGROUP.dll' name 'MFCreateSensorProfile';
result := DllCall("MFSENSORGROUP\MFCreateSensorProfile"
    , "Ptr", ProfileType   ; GUID*
    , "UInt", ProfileIndex   ; DWORD
    , "WStr", Constraints   ; LPCWSTR optional
    , "Ptr", ppProfile   ; IMFSensorProfile** out
    , "Int")   ; return: HRESULT
●MFCreateSensorProfile(ProfileType, ProfileIndex, Constraints, ppProfile) = DLL("MFSENSORGROUP.dll", "int MFCreateSensorProfile(void*, dword, char*, void*)")
# 呼び出し: MFCreateSensorProfile(ProfileType, ProfileIndex, Constraints, ppProfile)
# ProfileType : GUID* -> "void*"
# ProfileIndex : DWORD -> "dword"
# Constraints : LPCWSTR optional -> "char*"
# ppProfile : IMFSensorProfile** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "mfsensorgroup" fn MFCreateSensorProfile(
    ProfileType: [*c]GUID, // GUID*
    ProfileIndex: u32, // DWORD
    Constraints: [*c]const u16, // LPCWSTR optional
    ppProfile: ?*anyopaque // IMFSensorProfile** out
) callconv(std.os.windows.WINAPI) i32;
proc MFCreateSensorProfile(
    ProfileType: ptr GUID,  # GUID*
    ProfileIndex: uint32,  # DWORD
    Constraints: WideCString,  # LPCWSTR optional
    ppProfile: pointer  # IMFSensorProfile** out
): int32 {.importc: "MFCreateSensorProfile", stdcall, dynlib: "MFSENSORGROUP.dll".}
pragma(lib, "mfsensorgroup");
extern(Windows)
int MFCreateSensorProfile(
    GUID* ProfileType,   // GUID*
    uint ProfileIndex,   // DWORD
    const(wchar)* Constraints,   // LPCWSTR optional
    void* ppProfile   // IMFSensorProfile** out
);
ccall((:MFCreateSensorProfile, "MFSENSORGROUP.dll"), stdcall, Int32,
      (Ptr{GUID}, UInt32, Cwstring, Ptr{Cvoid}),
      ProfileType, ProfileIndex, Constraints, ppProfile)
# ProfileType : GUID* -> Ptr{GUID}
# ProfileIndex : DWORD -> UInt32
# Constraints : LPCWSTR optional -> Cwstring
# ppProfile : IMFSensorProfile** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t MFCreateSensorProfile(
    void* ProfileType,
    uint32_t ProfileIndex,
    const uint16_t* Constraints,
    void* ppProfile);
]]
local mfsensorgroup = ffi.load("mfsensorgroup")
-- mfsensorgroup.MFCreateSensorProfile(ProfileType, ProfileIndex, Constraints, ppProfile)
-- ProfileType : GUID*
-- ProfileIndex : DWORD
-- Constraints : LPCWSTR optional
-- ppProfile : IMFSensorProfile** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('MFSENSORGROUP.dll');
const MFCreateSensorProfile = lib.func('__stdcall', 'MFCreateSensorProfile', 'int32_t', ['void *', 'uint32_t', 'str16', 'void *']);
// MFCreateSensorProfile(ProfileType, ProfileIndex, Constraints, ppProfile)
// ProfileType : GUID* -> 'void *'
// ProfileIndex : DWORD -> 'uint32_t'
// Constraints : LPCWSTR optional -> 'str16'
// ppProfile : IMFSensorProfile** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("MFSENSORGROUP.dll", {
  MFCreateSensorProfile: { parameters: ["pointer", "u32", "buffer", "pointer"], result: "i32" },
});
// lib.symbols.MFCreateSensorProfile(ProfileType, ProfileIndex, Constraints, ppProfile)
// ProfileType : GUID* -> "pointer"
// ProfileIndex : DWORD -> "u32"
// Constraints : LPCWSTR optional -> "buffer"
// ppProfile : IMFSensorProfile** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t MFCreateSensorProfile(
    void* ProfileType,
    uint32_t ProfileIndex,
    const uint16_t* Constraints,
    void* ppProfile);
C, "MFSENSORGROUP.dll");
// $ffi->MFCreateSensorProfile(ProfileType, ProfileIndex, Constraints, ppProfile);
// ProfileType : GUID*
// ProfileIndex : DWORD
// Constraints : LPCWSTR optional
// ppProfile : IMFSensorProfile** 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 Mfsensorgroup extends StdCallLibrary {
    Mfsensorgroup INSTANCE = Native.load("mfsensorgroup", Mfsensorgroup.class);
    int MFCreateSensorProfile(
        Pointer ProfileType,   // GUID*
        int ProfileIndex,   // DWORD
        WString Constraints,   // LPCWSTR optional
        Pointer ppProfile   // IMFSensorProfile** out
    );
}
@[Link("mfsensorgroup")]
lib LibMFSENSORGROUP
  fun MFCreateSensorProfile = MFCreateSensorProfile(
    ProfileType : GUID*,   # GUID*
    ProfileIndex : UInt32,   # DWORD
    Constraints : UInt16*,   # LPCWSTR optional
    ppProfile : Void*   # IMFSensorProfile** out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef MFCreateSensorProfileNative = Int32 Function(Pointer<Void>, Uint32, Pointer<Utf16>, Pointer<Void>);
typedef MFCreateSensorProfileDart = int Function(Pointer<Void>, int, Pointer<Utf16>, Pointer<Void>);
final MFCreateSensorProfile = DynamicLibrary.open('MFSENSORGROUP.dll')
    .lookupFunction<MFCreateSensorProfileNative, MFCreateSensorProfileDart>('MFCreateSensorProfile');
// ProfileType : GUID* -> Pointer<Void>
// ProfileIndex : DWORD -> Uint32
// Constraints : LPCWSTR optional -> Pointer<Utf16>
// ppProfile : IMFSensorProfile** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function MFCreateSensorProfile(
  ProfileType: PGUID;   // GUID*
  ProfileIndex: DWORD;   // DWORD
  Constraints: PWideChar;   // LPCWSTR optional
  ppProfile: Pointer   // IMFSensorProfile** out
): Integer; stdcall;
  external 'MFSENSORGROUP.dll' name 'MFCreateSensorProfile';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "MFCreateSensorProfile"
  c_MFCreateSensorProfile :: Ptr () -> Word32 -> CWString -> Ptr () -> IO Int32
-- ProfileType : GUID* -> Ptr ()
-- ProfileIndex : DWORD -> Word32
-- Constraints : LPCWSTR optional -> CWString
-- ppProfile : IMFSensorProfile** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let mfcreatesensorprofile =
  foreign "MFCreateSensorProfile"
    ((ptr void) @-> uint32_t @-> (ptr uint16_t) @-> (ptr void) @-> returning int32_t)
(* ProfileType : GUID* -> (ptr void) *)
(* ProfileIndex : DWORD -> uint32_t *)
(* Constraints : LPCWSTR optional -> (ptr uint16_t) *)
(* ppProfile : IMFSensorProfile** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library mfsensorgroup (t "MFSENSORGROUP.dll"))
(cffi:use-foreign-library mfsensorgroup)

(cffi:defcfun ("MFCreateSensorProfile" mfcreate-sensor-profile :convention :stdcall) :int32
  (profile-type :pointer)   ; GUID*
  (profile-index :uint32)   ; DWORD
  (constraints (:string :encoding :utf-16le))   ; LPCWSTR optional
  (pp-profile :pointer))   ; IMFSensorProfile** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $MFCreateSensorProfile = Win32::API::More->new('MFSENSORGROUP',
    'int MFCreateSensorProfile(LPVOID ProfileType, DWORD ProfileIndex, LPCWSTR Constraints, LPVOID ppProfile)');
# my $ret = $MFCreateSensorProfile->Call($ProfileType, $ProfileIndex, $Constraints, $ppProfile);
# ProfileType : GUID* -> LPVOID
# ProfileIndex : DWORD -> DWORD
# Constraints : LPCWSTR optional -> LPCWSTR
# ppProfile : IMFSensorProfile** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型