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

CreateCaptureAudioStateMonitorForCategoryAndDeviceId

関数
カテゴリとデバイスID指定でキャプチャ状態監視を生成する。
DLLWindows.Media.MediaControl.dll呼出規約winapi

シグネチャ

// Windows.Media.MediaControl.dll
#include <windows.h>

HRESULT CreateCaptureAudioStateMonitorForCategoryAndDeviceId(
    AUDIO_STREAM_CATEGORY category,
    LPCWSTR deviceId,
    IAudioStateMonitor** audioStateMonitor
);

パラメーター

名前方向
categoryAUDIO_STREAM_CATEGORYin
deviceIdLPCWSTRin
audioStateMonitorIAudioStateMonitor**out

戻り値の型: HRESULT

各言語での呼び出し定義

// Windows.Media.MediaControl.dll
#include <windows.h>

HRESULT CreateCaptureAudioStateMonitorForCategoryAndDeviceId(
    AUDIO_STREAM_CATEGORY category,
    LPCWSTR deviceId,
    IAudioStateMonitor** audioStateMonitor
);
[DllImport("Windows.Media.MediaControl.dll", ExactSpelling = true)]
static extern int CreateCaptureAudioStateMonitorForCategoryAndDeviceId(
    int category,   // AUDIO_STREAM_CATEGORY
    [MarshalAs(UnmanagedType.LPWStr)] string deviceId,   // LPCWSTR
    IntPtr audioStateMonitor   // IAudioStateMonitor** out
);
<DllImport("Windows.Media.MediaControl.dll", ExactSpelling:=True)>
Public Shared Function CreateCaptureAudioStateMonitorForCategoryAndDeviceId(
    category As Integer,   ' AUDIO_STREAM_CATEGORY
    <MarshalAs(UnmanagedType.LPWStr)> deviceId As String,   ' LPCWSTR
    audioStateMonitor As IntPtr   ' IAudioStateMonitor** out
) As Integer
End Function
' category : AUDIO_STREAM_CATEGORY
' deviceId : LPCWSTR
' audioStateMonitor : IAudioStateMonitor** out
Declare PtrSafe Function CreateCaptureAudioStateMonitorForCategoryAndDeviceId Lib "windows.media.mediacontrol" ( _
    ByVal category As Long, _
    ByVal deviceId As LongPtr, _
    ByVal audioStateMonitor As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CreateCaptureAudioStateMonitorForCategoryAndDeviceId = ctypes.windll.LoadLibrary("Windows.Media.MediaControl.dll").CreateCaptureAudioStateMonitorForCategoryAndDeviceId
CreateCaptureAudioStateMonitorForCategoryAndDeviceId.restype = ctypes.c_int
CreateCaptureAudioStateMonitorForCategoryAndDeviceId.argtypes = [
    ctypes.c_int,  # category : AUDIO_STREAM_CATEGORY
    wintypes.LPCWSTR,  # deviceId : LPCWSTR
    ctypes.c_void_p,  # audioStateMonitor : IAudioStateMonitor** out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	windows_media_mediacontrol = windows.NewLazySystemDLL("Windows.Media.MediaControl.dll")
	procCreateCaptureAudioStateMonitorForCategoryAndDeviceId = windows_media_mediacontrol.NewProc("CreateCaptureAudioStateMonitorForCategoryAndDeviceId")
)

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