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パイプ情報を問い合わせる対象のWinUSBインターフェイスハンドル。
AlternateInterfaceNumberBYTEin対象とする代替インターフェイス設定の番号(0始まり)。
PipeIndexBYTEin問い合わせるパイプ(エンドポイント)のインデックス(0始まり)。
PipeInformationWINUSB_PIPE_INFORMATION*out取得したパイプ情報を格納するWINUSB_PIPE_INFORMATION構造体へのポインタ。

戻り値の型: 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 <MarshalAs(UnmanagedType.Bool)> 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)。
const std = @import("std");

extern "winusb" fn WinUsb_QueryPipe(
    InterfaceHandle: ?*anyopaque, // WINUSB_INTERFACE_HANDLE
    AlternateInterfaceNumber: u8, // BYTE
    PipeIndex: u8, // BYTE
    PipeInformation: [*c]WINUSB_PIPE_INFORMATION // WINUSB_PIPE_INFORMATION* out
) callconv(std.os.windows.WINAPI) i32;
proc WinUsb_QueryPipe(
    InterfaceHandle: pointer,  # WINUSB_INTERFACE_HANDLE
    AlternateInterfaceNumber: uint8,  # BYTE
    PipeIndex: uint8,  # BYTE
    PipeInformation: ptr WINUSB_PIPE_INFORMATION  # WINUSB_PIPE_INFORMATION* out
): int32 {.importc: "WinUsb_QueryPipe", stdcall, dynlib: "WINUSB.dll".}
pragma(lib, "winusb");
extern(Windows)
int WinUsb_QueryPipe(
    void* InterfaceHandle,   // WINUSB_INTERFACE_HANDLE
    ubyte AlternateInterfaceNumber,   // BYTE
    ubyte PipeIndex,   // BYTE
    WINUSB_PIPE_INFORMATION* PipeInformation   // WINUSB_PIPE_INFORMATION* out
);
ccall((:WinUsb_QueryPipe, "WINUSB.dll"), stdcall, Int32,
      (Ptr{Cvoid}, UInt8, UInt8, Ptr{WINUSB_PIPE_INFORMATION}),
      InterfaceHandle, AlternateInterfaceNumber, PipeIndex, PipeInformation)
# InterfaceHandle : WINUSB_INTERFACE_HANDLE -> Ptr{Cvoid}
# AlternateInterfaceNumber : BYTE -> UInt8
# PipeIndex : BYTE -> UInt8
# PipeInformation : WINUSB_PIPE_INFORMATION* out -> Ptr{WINUSB_PIPE_INFORMATION}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t WinUsb_QueryPipe(
    void* InterfaceHandle,
    uint8_t AlternateInterfaceNumber,
    uint8_t PipeIndex,
    void* PipeInformation);
]]
local winusb = ffi.load("winusb")
-- winusb.WinUsb_QueryPipe(InterfaceHandle, AlternateInterfaceNumber, PipeIndex, PipeInformation)
-- InterfaceHandle : WINUSB_INTERFACE_HANDLE
-- AlternateInterfaceNumber : BYTE
-- PipeIndex : BYTE
-- PipeInformation : WINUSB_PIPE_INFORMATION* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('WINUSB.dll');
const WinUsb_QueryPipe = lib.func('__stdcall', 'WinUsb_QueryPipe', 'int32_t', ['void *', 'uint8_t', 'uint8_t', 'void *']);
// WinUsb_QueryPipe(InterfaceHandle, AlternateInterfaceNumber, PipeIndex, PipeInformation)
// InterfaceHandle : WINUSB_INTERFACE_HANDLE -> 'void *'
// AlternateInterfaceNumber : BYTE -> 'uint8_t'
// PipeIndex : BYTE -> 'uint8_t'
// PipeInformation : WINUSB_PIPE_INFORMATION* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("WINUSB.dll", {
  WinUsb_QueryPipe: { parameters: ["pointer", "u8", "u8", "pointer"], result: "i32" },
});
// lib.symbols.WinUsb_QueryPipe(InterfaceHandle, AlternateInterfaceNumber, PipeIndex, PipeInformation)
// InterfaceHandle : WINUSB_INTERFACE_HANDLE -> "pointer"
// AlternateInterfaceNumber : BYTE -> "u8"
// PipeIndex : BYTE -> "u8"
// PipeInformation : WINUSB_PIPE_INFORMATION* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t WinUsb_QueryPipe(
    void* InterfaceHandle,
    uint8_t AlternateInterfaceNumber,
    uint8_t PipeIndex,
    void* PipeInformation);
C, "WINUSB.dll");
// $ffi->WinUsb_QueryPipe(InterfaceHandle, AlternateInterfaceNumber, PipeIndex, PipeInformation);
// InterfaceHandle : WINUSB_INTERFACE_HANDLE
// AlternateInterfaceNumber : BYTE
// PipeIndex : BYTE
// PipeInformation : WINUSB_PIPE_INFORMATION* out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Winusb extends StdCallLibrary {
    Winusb INSTANCE = Native.load("winusb", Winusb.class);
    boolean WinUsb_QueryPipe(
        Pointer InterfaceHandle,   // WINUSB_INTERFACE_HANDLE
        byte AlternateInterfaceNumber,   // BYTE
        byte PipeIndex,   // BYTE
        Pointer PipeInformation   // WINUSB_PIPE_INFORMATION* out
    );
}
@[Link("winusb")]
lib LibWINUSB
  fun WinUsb_QueryPipe = WinUsb_QueryPipe(
    InterfaceHandle : Void*,   # WINUSB_INTERFACE_HANDLE
    AlternateInterfaceNumber : UInt8,   # BYTE
    PipeIndex : UInt8,   # BYTE
    PipeInformation : WINUSB_PIPE_INFORMATION*   # WINUSB_PIPE_INFORMATION* out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef WinUsb_QueryPipeNative = Int32 Function(Pointer<Void>, Uint8, Uint8, Pointer<Void>);
typedef WinUsb_QueryPipeDart = int Function(Pointer<Void>, int, int, Pointer<Void>);
final WinUsb_QueryPipe = DynamicLibrary.open('WINUSB.dll')
    .lookupFunction<WinUsb_QueryPipeNative, WinUsb_QueryPipeDart>('WinUsb_QueryPipe');
// InterfaceHandle : WINUSB_INTERFACE_HANDLE -> Pointer<Void>
// AlternateInterfaceNumber : BYTE -> Uint8
// PipeIndex : BYTE -> Uint8
// PipeInformation : WINUSB_PIPE_INFORMATION* out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
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';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WinUsb_QueryPipe"
  c_WinUsb_QueryPipe :: Ptr () -> Word8 -> Word8 -> Ptr () -> IO CInt
-- InterfaceHandle : WINUSB_INTERFACE_HANDLE -> Ptr ()
-- AlternateInterfaceNumber : BYTE -> Word8
-- PipeIndex : BYTE -> Word8
-- PipeInformation : WINUSB_PIPE_INFORMATION* out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let winusb_querypipe =
  foreign "WinUsb_QueryPipe"
    ((ptr void) @-> uint8_t @-> uint8_t @-> (ptr void) @-> returning int32_t)
(* InterfaceHandle : WINUSB_INTERFACE_HANDLE -> (ptr void) *)
(* AlternateInterfaceNumber : BYTE -> uint8_t *)
(* PipeIndex : BYTE -> uint8_t *)
(* PipeInformation : WINUSB_PIPE_INFORMATION* out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library winusb (t "WINUSB.dll"))
(cffi:use-foreign-library winusb)

(cffi:defcfun ("WinUsb_QueryPipe" win-usb-query-pipe :convention :stdcall) :int32
  (interface-handle :pointer)   ; WINUSB_INTERFACE_HANDLE
  (alternate-interface-number :uint8)   ; BYTE
  (pipe-index :uint8)   ; BYTE
  (pipe-information :pointer))   ; WINUSB_PIPE_INFORMATION* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WinUsb_QueryPipe = Win32::API::More->new('WINUSB',
    'BOOL WinUsb_QueryPipe(HANDLE InterfaceHandle, BYTE AlternateInterfaceNumber, BYTE PipeIndex, LPVOID PipeInformation)');
# my $ret = $WinUsb_QueryPipe->Call($InterfaceHandle, $AlternateInterfaceNumber, $PipeIndex, $PipeInformation);
# InterfaceHandle : WINUSB_INTERFACE_HANDLE -> HANDLE
# AlternateInterfaceNumber : BYTE -> BYTE
# PipeIndex : BYTE -> BYTE
# PipeInformation : WINUSB_PIPE_INFORMATION* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

類似 API
使用する型