ホーム › Media.MediaFoundation › MFAllocateWorkQueue
MFAllocateWorkQueue
関数新しい非公開作業キューを割り当てる。
シグネチャ
// MFPlat.dll
#include <windows.h>
HRESULT MFAllocateWorkQueue(
DWORD* pdwWorkQueue
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pdwWorkQueue | DWORD* | out | ワークキューの識別子を受け取ります。 |
戻り値の型: HRESULT
公式ドキュメント
新しいワークキューを作成します。(MFAllocateWorkQueue)
戻り値
この関数は HRESULT を返します。指定できる値には次の表に示すものがありますが、これらに限定されません。
| 戻り値 | 説明 |
|---|---|
| 関数は成功しました。 | |
| アプリケーションがワークキューの最大数を超えました。 | |
| アプリケーションが MFStartup を呼び出していないか、すでに MFShutdown を呼び出しています。 |
解説(Remarks)
ワークキューの使用が終わったら、MFUnlockWorkQueue を呼び出してください。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// MFPlat.dll
#include <windows.h>
HRESULT MFAllocateWorkQueue(
DWORD* pdwWorkQueue
);[DllImport("MFPlat.dll", ExactSpelling = true)]
static extern int MFAllocateWorkQueue(
out uint pdwWorkQueue // DWORD* out
);<DllImport("MFPlat.dll", ExactSpelling:=True)>
Public Shared Function MFAllocateWorkQueue(
<Out> ByRef pdwWorkQueue As UInteger ' DWORD* out
) As Integer
End Function' pdwWorkQueue : DWORD* out
Declare PtrSafe Function MFAllocateWorkQueue Lib "mfplat" ( _
ByRef pdwWorkQueue As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
MFAllocateWorkQueue = ctypes.windll.mfplat.MFAllocateWorkQueue
MFAllocateWorkQueue.restype = ctypes.c_int
MFAllocateWorkQueue.argtypes = [
ctypes.POINTER(wintypes.DWORD), # pdwWorkQueue : DWORD* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('MFPlat.dll')
MFAllocateWorkQueue = Fiddle::Function.new(
lib['MFAllocateWorkQueue'],
[
Fiddle::TYPE_VOIDP, # pdwWorkQueue : DWORD* out
],
Fiddle::TYPE_INT)#[link(name = "mfplat")]
extern "system" {
fn MFAllocateWorkQueue(
pdwWorkQueue: *mut u32 // DWORD* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("MFPlat.dll")]
public static extern int MFAllocateWorkQueue(out uint pdwWorkQueue);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MFPlat_MFAllocateWorkQueue' -Namespace Win32 -PassThru
# $api::MFAllocateWorkQueue(pdwWorkQueue)#uselib "MFPlat.dll"
#func global MFAllocateWorkQueue "MFAllocateWorkQueue" sptr
; MFAllocateWorkQueue varptr(pdwWorkQueue) ; 戻り値は stat
; pdwWorkQueue : DWORD* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "MFPlat.dll" #cfunc global MFAllocateWorkQueue "MFAllocateWorkQueue" var ; res = MFAllocateWorkQueue(pdwWorkQueue) ; pdwWorkQueue : DWORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "MFPlat.dll" #cfunc global MFAllocateWorkQueue "MFAllocateWorkQueue" sptr ; res = MFAllocateWorkQueue(varptr(pdwWorkQueue)) ; pdwWorkQueue : DWORD* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT MFAllocateWorkQueue(DWORD* pdwWorkQueue) #uselib "MFPlat.dll" #cfunc global MFAllocateWorkQueue "MFAllocateWorkQueue" var ; res = MFAllocateWorkQueue(pdwWorkQueue) ; pdwWorkQueue : DWORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT MFAllocateWorkQueue(DWORD* pdwWorkQueue) #uselib "MFPlat.dll" #cfunc global MFAllocateWorkQueue "MFAllocateWorkQueue" intptr ; res = MFAllocateWorkQueue(varptr(pdwWorkQueue)) ; pdwWorkQueue : DWORD* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
mfplat = windows.NewLazySystemDLL("MFPlat.dll")
procMFAllocateWorkQueue = mfplat.NewProc("MFAllocateWorkQueue")
)
// pdwWorkQueue (DWORD* out)
r1, _, err := procMFAllocateWorkQueue.Call(
uintptr(pdwWorkQueue),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction MFAllocateWorkQueue(
pdwWorkQueue: Pointer // DWORD* out
): Integer; stdcall;
external 'MFPlat.dll' name 'MFAllocateWorkQueue';result := DllCall("MFPlat\MFAllocateWorkQueue"
, "Ptr", pdwWorkQueue ; DWORD* out
, "Int") ; return: HRESULT●MFAllocateWorkQueue(pdwWorkQueue) = DLL("MFPlat.dll", "int MFAllocateWorkQueue(void*)")
# 呼び出し: MFAllocateWorkQueue(pdwWorkQueue)
# pdwWorkQueue : DWORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "mfplat" fn MFAllocateWorkQueue(
pdwWorkQueue: [*c]u32 // DWORD* out
) callconv(std.os.windows.WINAPI) i32;proc MFAllocateWorkQueue(
pdwWorkQueue: ptr uint32 # DWORD* out
): int32 {.importc: "MFAllocateWorkQueue", stdcall, dynlib: "MFPlat.dll".}pragma(lib, "mfplat");
extern(Windows)
int MFAllocateWorkQueue(
uint* pdwWorkQueue // DWORD* out
);ccall((:MFAllocateWorkQueue, "MFPlat.dll"), stdcall, Int32,
(Ptr{UInt32},),
pdwWorkQueue)
# pdwWorkQueue : DWORD* out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t MFAllocateWorkQueue(
uint32_t* pdwWorkQueue);
]]
local mfplat = ffi.load("mfplat")
-- mfplat.MFAllocateWorkQueue(pdwWorkQueue)
-- pdwWorkQueue : DWORD* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('MFPlat.dll');
const MFAllocateWorkQueue = lib.func('__stdcall', 'MFAllocateWorkQueue', 'int32_t', ['uint32_t *']);
// MFAllocateWorkQueue(pdwWorkQueue)
// pdwWorkQueue : DWORD* out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("MFPlat.dll", {
MFAllocateWorkQueue: { parameters: ["pointer"], result: "i32" },
});
// lib.symbols.MFAllocateWorkQueue(pdwWorkQueue)
// pdwWorkQueue : DWORD* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t MFAllocateWorkQueue(
uint32_t* pdwWorkQueue);
C, "MFPlat.dll");
// $ffi->MFAllocateWorkQueue(pdwWorkQueue);
// pdwWorkQueue : DWORD* 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 Mfplat extends StdCallLibrary {
Mfplat INSTANCE = Native.load("mfplat", Mfplat.class);
int MFAllocateWorkQueue(
IntByReference pdwWorkQueue // DWORD* out
);
}@[Link("mfplat")]
lib LibMFPlat
fun MFAllocateWorkQueue = MFAllocateWorkQueue(
pdwWorkQueue : UInt32* # DWORD* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef MFAllocateWorkQueueNative = Int32 Function(Pointer<Uint32>);
typedef MFAllocateWorkQueueDart = int Function(Pointer<Uint32>);
final MFAllocateWorkQueue = DynamicLibrary.open('MFPlat.dll')
.lookupFunction<MFAllocateWorkQueueNative, MFAllocateWorkQueueDart>('MFAllocateWorkQueue');
// pdwWorkQueue : DWORD* out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function MFAllocateWorkQueue(
pdwWorkQueue: Pointer // DWORD* out
): Integer; stdcall;
external 'MFPlat.dll' name 'MFAllocateWorkQueue';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "MFAllocateWorkQueue"
c_MFAllocateWorkQueue :: Ptr Word32 -> IO Int32
-- pdwWorkQueue : DWORD* out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let mfallocateworkqueue =
foreign "MFAllocateWorkQueue"
((ptr uint32_t) @-> returning int32_t)
(* pdwWorkQueue : DWORD* out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library mfplat (t "MFPlat.dll"))
(cffi:use-foreign-library mfplat)
(cffi:defcfun ("MFAllocateWorkQueue" mfallocate-work-queue :convention :stdcall) :int32
(pdw-work-queue :pointer)) ; DWORD* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $MFAllocateWorkQueue = Win32::API::More->new('MFPlat',
'int MFAllocateWorkQueue(LPVOID pdwWorkQueue)');
# my $ret = $MFAllocateWorkQueue->Call($pdwWorkQueue);
# pdwWorkQueue : DWORD* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
類似 API
- f MFAllocateWorkQueueEx — 種別を指定して新しい作業キューを割り当てる。
公式の関連項目
- f MFPutWorkItem — 指定した作業キューに非同期作業項目を登録する。
- f MFPutWorkItemEx — 非同期結果オブジェクトを作業キューに登録する。