ホーム › Media.KernelStreaming › KsOpenDefaultDevice
KsOpenDefaultDevice
関数指定カテゴリの既定デバイスを開いてハンドルを取得する。
シグネチャ
// ksproxy.ax
#include <windows.h>
HRESULT KsOpenDefaultDevice(
const GUID* Category,
DWORD Access,
HANDLE* DeviceHandle
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| Category | GUID* | in |
| Access | DWORD | in |
| DeviceHandle | HANDLE* | out |
戻り値の型: HRESULT
各言語での呼び出し定義
// ksproxy.ax
#include <windows.h>
HRESULT KsOpenDefaultDevice(
const GUID* Category,
DWORD Access,
HANDLE* DeviceHandle
);[DllImport("ksproxy.ax", ExactSpelling = true)]
static extern int KsOpenDefaultDevice(
ref Guid Category, // GUID*
uint Access, // DWORD
IntPtr DeviceHandle // HANDLE* out
);<DllImport("ksproxy.ax", ExactSpelling:=True)>
Public Shared Function KsOpenDefaultDevice(
ByRef Category As Guid, ' GUID*
Access As UInteger, ' DWORD
DeviceHandle As IntPtr ' HANDLE* out
) As Integer
End Function' Category : GUID*
' Access : DWORD
' DeviceHandle : HANDLE* out
Declare PtrSafe Function KsOpenDefaultDevice Lib "ksproxy.ax" ( _
ByVal Category As LongPtr, _
ByVal Access As Long, _
ByVal DeviceHandle As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
KsOpenDefaultDevice = ctypes.windll.LoadLibrary("ksproxy.ax").KsOpenDefaultDevice
KsOpenDefaultDevice.restype = ctypes.c_int
KsOpenDefaultDevice.argtypes = [
ctypes.c_void_p, # Category : GUID*
wintypes.DWORD, # Access : DWORD
ctypes.c_void_p, # DeviceHandle : HANDLE* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ksproxy.ax')
KsOpenDefaultDevice = Fiddle::Function.new(
lib['KsOpenDefaultDevice'],
[
Fiddle::TYPE_VOIDP, # Category : GUID*
-Fiddle::TYPE_INT, # Access : DWORD
Fiddle::TYPE_VOIDP, # DeviceHandle : HANDLE* out
],
Fiddle::TYPE_INT)#[link(name = "ksproxy.ax")]
extern "system" {
fn KsOpenDefaultDevice(
Category: *const GUID, // GUID*
Access: u32, // DWORD
DeviceHandle: *mut *mut core::ffi::c_void // HANDLE* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ksproxy.ax")]
public static extern int KsOpenDefaultDevice(ref Guid Category, uint Access, IntPtr DeviceHandle);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ksproxy.ax_KsOpenDefaultDevice' -Namespace Win32 -PassThru
# $api::KsOpenDefaultDevice(Category, Access, DeviceHandle)#uselib "ksproxy.ax"
#func global KsOpenDefaultDevice "KsOpenDefaultDevice" sptr, sptr, sptr
; KsOpenDefaultDevice varptr(Category), Access, DeviceHandle ; 戻り値は stat
; Category : GUID* -> "sptr"
; Access : DWORD -> "sptr"
; DeviceHandle : HANDLE* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ksproxy.ax" #cfunc global KsOpenDefaultDevice "KsOpenDefaultDevice" var, int, sptr ; res = KsOpenDefaultDevice(Category, Access, DeviceHandle) ; Category : GUID* -> "var" ; Access : DWORD -> "int" ; DeviceHandle : HANDLE* out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ksproxy.ax" #cfunc global KsOpenDefaultDevice "KsOpenDefaultDevice" sptr, int, sptr ; res = KsOpenDefaultDevice(varptr(Category), Access, DeviceHandle) ; Category : GUID* -> "sptr" ; Access : DWORD -> "int" ; DeviceHandle : HANDLE* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT KsOpenDefaultDevice(GUID* Category, DWORD Access, HANDLE* DeviceHandle) #uselib "ksproxy.ax" #cfunc global KsOpenDefaultDevice "KsOpenDefaultDevice" var, int, intptr ; res = KsOpenDefaultDevice(Category, Access, DeviceHandle) ; Category : GUID* -> "var" ; Access : DWORD -> "int" ; DeviceHandle : HANDLE* out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT KsOpenDefaultDevice(GUID* Category, DWORD Access, HANDLE* DeviceHandle) #uselib "ksproxy.ax" #cfunc global KsOpenDefaultDevice "KsOpenDefaultDevice" intptr, int, intptr ; res = KsOpenDefaultDevice(varptr(Category), Access, DeviceHandle) ; Category : GUID* -> "intptr" ; Access : DWORD -> "int" ; DeviceHandle : HANDLE* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ksproxy_ax = windows.NewLazySystemDLL("ksproxy.ax")
procKsOpenDefaultDevice = ksproxy_ax.NewProc("KsOpenDefaultDevice")
)
// Category (GUID*), Access (DWORD), DeviceHandle (HANDLE* out)
r1, _, err := procKsOpenDefaultDevice.Call(
uintptr(Category),
uintptr(Access),
uintptr(DeviceHandle),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction KsOpenDefaultDevice(
Category: PGUID; // GUID*
Access: DWORD; // DWORD
DeviceHandle: Pointer // HANDLE* out
): Integer; stdcall;
external 'ksproxy.ax' name 'KsOpenDefaultDevice';result := DllCall("ksproxy.ax\KsOpenDefaultDevice"
, "Ptr", Category ; GUID*
, "UInt", Access ; DWORD
, "Ptr", DeviceHandle ; HANDLE* out
, "Int") ; return: HRESULT●KsOpenDefaultDevice(Category, Access, DeviceHandle) = DLL("ksproxy.ax", "int KsOpenDefaultDevice(void*, dword, void*)")
# 呼び出し: KsOpenDefaultDevice(Category, Access, DeviceHandle)
# Category : GUID* -> "void*"
# Access : DWORD -> "dword"
# DeviceHandle : HANDLE* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。