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