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

CreateRenderAudioStateMonitorForCategoryAndDeviceId

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

シグネチャ

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

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

パラメーター

名前方向
categoryAUDIO_STREAM_CATEGORYin
deviceIdLPCWSTRin
audioStateMonitorIAudioStateMonitor**out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT CreateRenderAudioStateMonitorForCategoryAndDeviceId(
    AUDIO_STREAM_CATEGORY category,
    LPCWSTR deviceId,
    IAudioStateMonitor** audioStateMonitor
);
[DllImport("Windows.Media.MediaControl.dll", ExactSpelling = true)]
static extern int CreateRenderAudioStateMonitorForCategoryAndDeviceId(
    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 CreateRenderAudioStateMonitorForCategoryAndDeviceId(
    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 CreateRenderAudioStateMonitorForCategoryAndDeviceId 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

CreateRenderAudioStateMonitorForCategoryAndDeviceId = ctypes.windll.LoadLibrary("Windows.Media.MediaControl.dll").CreateRenderAudioStateMonitorForCategoryAndDeviceId
CreateRenderAudioStateMonitorForCategoryAndDeviceId.restype = ctypes.c_int
CreateRenderAudioStateMonitorForCategoryAndDeviceId.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')
CreateRenderAudioStateMonitorForCategoryAndDeviceId = Fiddle::Function.new(
  lib['CreateRenderAudioStateMonitorForCategoryAndDeviceId'],
  [
    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 CreateRenderAudioStateMonitorForCategoryAndDeviceId(
        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 CreateRenderAudioStateMonitorForCategoryAndDeviceId(int category, [MarshalAs(UnmanagedType.LPWStr)] string deviceId, IntPtr audioStateMonitor);
"@
$api = Add-Type -MemberDefinition $sig -Name 'Windows.Media.MediaControl_CreateRenderAudioStateMonitorForCategoryAndDeviceId' -Namespace Win32 -PassThru
# $api::CreateRenderAudioStateMonitorForCategoryAndDeviceId(category, deviceId, audioStateMonitor)
#uselib "Windows.Media.MediaControl.dll"
#func global CreateRenderAudioStateMonitorForCategoryAndDeviceId "CreateRenderAudioStateMonitorForCategoryAndDeviceId" sptr, sptr, sptr
; CreateRenderAudioStateMonitorForCategoryAndDeviceId 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 CreateRenderAudioStateMonitorForCategoryAndDeviceId "CreateRenderAudioStateMonitorForCategoryAndDeviceId" int, wstr, sptr
; res = CreateRenderAudioStateMonitorForCategoryAndDeviceId(category, deviceId, audioStateMonitor)
; category : AUDIO_STREAM_CATEGORY -> "int"
; deviceId : LPCWSTR -> "wstr"
; audioStateMonitor : IAudioStateMonitor** out -> "sptr"
; HRESULT CreateRenderAudioStateMonitorForCategoryAndDeviceId(AUDIO_STREAM_CATEGORY category, LPCWSTR deviceId, IAudioStateMonitor** audioStateMonitor)
#uselib "Windows.Media.MediaControl.dll"
#cfunc global CreateRenderAudioStateMonitorForCategoryAndDeviceId "CreateRenderAudioStateMonitorForCategoryAndDeviceId" int, wstr, intptr
; res = CreateRenderAudioStateMonitorForCategoryAndDeviceId(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")
	procCreateRenderAudioStateMonitorForCategoryAndDeviceId = windows_media_mediacontrol.NewProc("CreateRenderAudioStateMonitorForCategoryAndDeviceId")
)

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