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

WinUsb_QueryPipe

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

シグネチャ

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

BOOL WinUsb_QueryPipe(
    WINUSB_INTERFACE_HANDLE InterfaceHandle,
    BYTE AlternateInterfaceNumber,
    BYTE PipeIndex,
    WINUSB_PIPE_INFORMATION* PipeInformation
);

パラメーター

名前方向
InterfaceHandleWINUSB_INTERFACE_HANDLEin
AlternateInterfaceNumberBYTEin
PipeIndexBYTEin
PipeInformationWINUSB_PIPE_INFORMATION*out

戻り値の型: BOOL

各言語での呼び出し定義

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

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

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

lib = Fiddle.dlopen('WINUSB.dll')
WinUsb_QueryPipe = Fiddle::Function.new(
  lib['WinUsb_QueryPipe'],
  [
    Fiddle::TYPE_VOIDP,  # InterfaceHandle : WINUSB_INTERFACE_HANDLE
    -Fiddle::TYPE_CHAR,  # AlternateInterfaceNumber : BYTE
    -Fiddle::TYPE_CHAR,  # PipeIndex : BYTE
    Fiddle::TYPE_VOIDP,  # PipeInformation : WINUSB_PIPE_INFORMATION* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "winusb")]
extern "system" {
    fn WinUsb_QueryPipe(
        InterfaceHandle: *mut core::ffi::c_void,  // WINUSB_INTERFACE_HANDLE
        AlternateInterfaceNumber: u8,  // BYTE
        PipeIndex: u8,  // BYTE
        PipeInformation: *mut WINUSB_PIPE_INFORMATION  // WINUSB_PIPE_INFORMATION* 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_QueryPipe(IntPtr InterfaceHandle, byte AlternateInterfaceNumber, byte PipeIndex, IntPtr PipeInformation);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WINUSB_WinUsb_QueryPipe' -Namespace Win32 -PassThru
# $api::WinUsb_QueryPipe(InterfaceHandle, AlternateInterfaceNumber, PipeIndex, PipeInformation)
#uselib "WINUSB.dll"
#func global WinUsb_QueryPipe "WinUsb_QueryPipe" sptr, sptr, sptr, sptr
; WinUsb_QueryPipe InterfaceHandle, AlternateInterfaceNumber, PipeIndex, varptr(PipeInformation)   ; 戻り値は stat
; InterfaceHandle : WINUSB_INTERFACE_HANDLE -> "sptr"
; AlternateInterfaceNumber : BYTE -> "sptr"
; PipeIndex : BYTE -> "sptr"
; PipeInformation : WINUSB_PIPE_INFORMATION* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "WINUSB.dll"
#cfunc global WinUsb_QueryPipe "WinUsb_QueryPipe" sptr, int, int, var
; res = WinUsb_QueryPipe(InterfaceHandle, AlternateInterfaceNumber, PipeIndex, PipeInformation)
; InterfaceHandle : WINUSB_INTERFACE_HANDLE -> "sptr"
; AlternateInterfaceNumber : BYTE -> "int"
; PipeIndex : BYTE -> "int"
; PipeInformation : WINUSB_PIPE_INFORMATION* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL WinUsb_QueryPipe(WINUSB_INTERFACE_HANDLE InterfaceHandle, BYTE AlternateInterfaceNumber, BYTE PipeIndex, WINUSB_PIPE_INFORMATION* PipeInformation)
#uselib "WINUSB.dll"
#cfunc global WinUsb_QueryPipe "WinUsb_QueryPipe" intptr, int, int, var
; res = WinUsb_QueryPipe(InterfaceHandle, AlternateInterfaceNumber, PipeIndex, PipeInformation)
; InterfaceHandle : WINUSB_INTERFACE_HANDLE -> "intptr"
; AlternateInterfaceNumber : BYTE -> "int"
; PipeIndex : BYTE -> "int"
; PipeInformation : WINUSB_PIPE_INFORMATION* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	winusb = windows.NewLazySystemDLL("WINUSB.dll")
	procWinUsb_QueryPipe = winusb.NewProc("WinUsb_QueryPipe")
)

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