Win32 API 日本語リファレンス
ホームDevices.Usb › WinUsb_QueryPipeEx

WinUsb_QueryPipeEx

関数
指定したパイプの拡張エンドポイント情報を取得する。
DLLWINUSB.dll呼出規約winapiSetLastErrorあり

シグネチャ

// WINUSB.dll
#include <windows.h>

BOOL WinUsb_QueryPipeEx(
    WINUSB_INTERFACE_HANDLE InterfaceHandle,
    BYTE AlternateSettingNumber,
    BYTE PipeIndex,
    WINUSB_PIPE_INFORMATION_EX* PipeInformationEx
);

パラメーター

名前方向
InterfaceHandleWINUSB_INTERFACE_HANDLEin
AlternateSettingNumberBYTEin
PipeIndexBYTEin
PipeInformationExWINUSB_PIPE_INFORMATION_EX*out

戻り値の型: BOOL

各言語での呼び出し定義

// WINUSB.dll
#include <windows.h>

BOOL WinUsb_QueryPipeEx(
    WINUSB_INTERFACE_HANDLE InterfaceHandle,
    BYTE AlternateSettingNumber,
    BYTE PipeIndex,
    WINUSB_PIPE_INFORMATION_EX* PipeInformationEx
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WINUSB.dll", SetLastError = true, ExactSpelling = true)]
static extern bool WinUsb_QueryPipeEx(
    IntPtr InterfaceHandle,   // WINUSB_INTERFACE_HANDLE
    byte AlternateSettingNumber,   // BYTE
    byte PipeIndex,   // BYTE
    IntPtr PipeInformationEx   // WINUSB_PIPE_INFORMATION_EX* out
);
<DllImport("WINUSB.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function WinUsb_QueryPipeEx(
    InterfaceHandle As IntPtr,   ' WINUSB_INTERFACE_HANDLE
    AlternateSettingNumber As Byte,   ' BYTE
    PipeIndex As Byte,   ' BYTE
    PipeInformationEx As IntPtr   ' WINUSB_PIPE_INFORMATION_EX* out
) As Boolean
End Function
' InterfaceHandle : WINUSB_INTERFACE_HANDLE
' AlternateSettingNumber : BYTE
' PipeIndex : BYTE
' PipeInformationEx : WINUSB_PIPE_INFORMATION_EX* out
Declare PtrSafe Function WinUsb_QueryPipeEx Lib "winusb" ( _
    ByVal InterfaceHandle As LongPtr, _
    ByVal AlternateSettingNumber As Byte, _
    ByVal PipeIndex As Byte, _
    ByVal PipeInformationEx As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WinUsb_QueryPipeEx = ctypes.windll.winusb.WinUsb_QueryPipeEx
WinUsb_QueryPipeEx.restype = wintypes.BOOL
WinUsb_QueryPipeEx.argtypes = [
    wintypes.HANDLE,  # InterfaceHandle : WINUSB_INTERFACE_HANDLE
    ctypes.c_ubyte,  # AlternateSettingNumber : BYTE
    ctypes.c_ubyte,  # PipeIndex : BYTE
    ctypes.c_void_p,  # PipeInformationEx : WINUSB_PIPE_INFORMATION_EX* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WINUSB.dll')
WinUsb_QueryPipeEx = Fiddle::Function.new(
  lib['WinUsb_QueryPipeEx'],
  [
    Fiddle::TYPE_VOIDP,  # InterfaceHandle : WINUSB_INTERFACE_HANDLE
    -Fiddle::TYPE_CHAR,  # AlternateSettingNumber : BYTE
    -Fiddle::TYPE_CHAR,  # PipeIndex : BYTE
    Fiddle::TYPE_VOIDP,  # PipeInformationEx : WINUSB_PIPE_INFORMATION_EX* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "winusb")]
extern "system" {
    fn WinUsb_QueryPipeEx(
        InterfaceHandle: *mut core::ffi::c_void,  // WINUSB_INTERFACE_HANDLE
        AlternateSettingNumber: u8,  // BYTE
        PipeIndex: u8,  // BYTE
        PipeInformationEx: *mut WINUSB_PIPE_INFORMATION_EX  // WINUSB_PIPE_INFORMATION_EX* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WINUSB.dll", SetLastError = true)]
public static extern bool WinUsb_QueryPipeEx(IntPtr InterfaceHandle, byte AlternateSettingNumber, byte PipeIndex, IntPtr PipeInformationEx);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WINUSB_WinUsb_QueryPipeEx' -Namespace Win32 -PassThru
# $api::WinUsb_QueryPipeEx(InterfaceHandle, AlternateSettingNumber, PipeIndex, PipeInformationEx)
#uselib "WINUSB.dll"
#func global WinUsb_QueryPipeEx "WinUsb_QueryPipeEx" sptr, sptr, sptr, sptr
; WinUsb_QueryPipeEx InterfaceHandle, AlternateSettingNumber, PipeIndex, varptr(PipeInformationEx)   ; 戻り値は stat
; InterfaceHandle : WINUSB_INTERFACE_HANDLE -> "sptr"
; AlternateSettingNumber : BYTE -> "sptr"
; PipeIndex : BYTE -> "sptr"
; PipeInformationEx : WINUSB_PIPE_INFORMATION_EX* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "WINUSB.dll"
#cfunc global WinUsb_QueryPipeEx "WinUsb_QueryPipeEx" sptr, int, int, var
; res = WinUsb_QueryPipeEx(InterfaceHandle, AlternateSettingNumber, PipeIndex, PipeInformationEx)
; InterfaceHandle : WINUSB_INTERFACE_HANDLE -> "sptr"
; AlternateSettingNumber : BYTE -> "int"
; PipeIndex : BYTE -> "int"
; PipeInformationEx : WINUSB_PIPE_INFORMATION_EX* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL WinUsb_QueryPipeEx(WINUSB_INTERFACE_HANDLE InterfaceHandle, BYTE AlternateSettingNumber, BYTE PipeIndex, WINUSB_PIPE_INFORMATION_EX* PipeInformationEx)
#uselib "WINUSB.dll"
#cfunc global WinUsb_QueryPipeEx "WinUsb_QueryPipeEx" intptr, int, int, var
; res = WinUsb_QueryPipeEx(InterfaceHandle, AlternateSettingNumber, PipeIndex, PipeInformationEx)
; InterfaceHandle : WINUSB_INTERFACE_HANDLE -> "intptr"
; AlternateSettingNumber : BYTE -> "int"
; PipeIndex : BYTE -> "int"
; PipeInformationEx : WINUSB_PIPE_INFORMATION_EX* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	winusb = windows.NewLazySystemDLL("WINUSB.dll")
	procWinUsb_QueryPipeEx = winusb.NewProc("WinUsb_QueryPipeEx")
)

// InterfaceHandle (WINUSB_INTERFACE_HANDLE), AlternateSettingNumber (BYTE), PipeIndex (BYTE), PipeInformationEx (WINUSB_PIPE_INFORMATION_EX* out)
r1, _, err := procWinUsb_QueryPipeEx.Call(
	uintptr(InterfaceHandle),
	uintptr(AlternateSettingNumber),
	uintptr(PipeIndex),
	uintptr(PipeInformationEx),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function WinUsb_QueryPipeEx(
  InterfaceHandle: THandle;   // WINUSB_INTERFACE_HANDLE
  AlternateSettingNumber: Byte;   // BYTE
  PipeIndex: Byte;   // BYTE
  PipeInformationEx: Pointer   // WINUSB_PIPE_INFORMATION_EX* out
): BOOL; stdcall;
  external 'WINUSB.dll' name 'WinUsb_QueryPipeEx';
result := DllCall("WINUSB\WinUsb_QueryPipeEx"
    , "Ptr", InterfaceHandle   ; WINUSB_INTERFACE_HANDLE
    , "UChar", AlternateSettingNumber   ; BYTE
    , "UChar", PipeIndex   ; BYTE
    , "Ptr", PipeInformationEx   ; WINUSB_PIPE_INFORMATION_EX* out
    , "Int")   ; return: BOOL
●WinUsb_QueryPipeEx(InterfaceHandle, AlternateSettingNumber, PipeIndex, PipeInformationEx) = DLL("WINUSB.dll", "bool WinUsb_QueryPipeEx(void*, byte, byte, void*)")
# 呼び出し: WinUsb_QueryPipeEx(InterfaceHandle, AlternateSettingNumber, PipeIndex, PipeInformationEx)
# InterfaceHandle : WINUSB_INTERFACE_HANDLE -> "void*"
# AlternateSettingNumber : BYTE -> "byte"
# PipeIndex : BYTE -> "byte"
# PipeInformationEx : WINUSB_PIPE_INFORMATION_EX* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。