ホーム › Devices.Usb › WinUsb_QueryPipeEx
WinUsb_QueryPipeEx
関数指定したパイプの拡張エンドポイント情報を取得する。
シグネチャ
// WINUSB.dll
#include <windows.h>
BOOL WinUsb_QueryPipeEx(
WINUSB_INTERFACE_HANDLE InterfaceHandle,
BYTE AlternateSettingNumber,
BYTE PipeIndex,
WINUSB_PIPE_INFORMATION_EX* PipeInformationEx
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| InterfaceHandle | WINUSB_INTERFACE_HANDLE | in | パイプ情報を問い合わせる対象のWinUSBインターフェイスハンドル。 |
| AlternateSettingNumber | BYTE | in | 対象とする代替インターフェイス設定の番号(0始まり)。 |
| PipeIndex | BYTE | in | 問い合わせるパイプ(エンドポイント)のインデックス(0始まり)。 |
| PipeInformationEx | WINUSB_PIPE_INFORMATION_EX* | out | 拡張パイプ情報を格納するWINUSB_PIPE_INFORMATION_EX構造体へのポインタ。 |
戻り値の型: 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 <MarshalAs(UnmanagedType.Bool)> 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 方式にも切替可。#uselib "WINUSB.dll" #cfunc global WinUsb_QueryPipeEx "WinUsb_QueryPipeEx" sptr, int, int, sptr ; res = WinUsb_QueryPipeEx(InterfaceHandle, AlternateSettingNumber, PipeIndex, varptr(PipeInformationEx)) ; InterfaceHandle : WINUSB_INTERFACE_HANDLE -> "sptr" ; AlternateSettingNumber : BYTE -> "int" ; PipeIndex : BYTE -> "int" ; PipeInformationEx : WINUSB_PIPE_INFORMATION_EX* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; 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, intptr ; res = WinUsb_QueryPipeEx(InterfaceHandle, AlternateSettingNumber, PipeIndex, varptr(PipeInformationEx)) ; InterfaceHandle : WINUSB_INTERFACE_HANDLE -> "intptr" ; AlternateSettingNumber : BYTE -> "int" ; PipeIndex : BYTE -> "int" ; PipeInformationEx : WINUSB_PIPE_INFORMATION_EX* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // BOOLfunction 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)。const std = @import("std");
extern "winusb" fn WinUsb_QueryPipeEx(
InterfaceHandle: ?*anyopaque, // WINUSB_INTERFACE_HANDLE
AlternateSettingNumber: u8, // BYTE
PipeIndex: u8, // BYTE
PipeInformationEx: [*c]WINUSB_PIPE_INFORMATION_EX // WINUSB_PIPE_INFORMATION_EX* out
) callconv(std.os.windows.WINAPI) i32;proc WinUsb_QueryPipeEx(
InterfaceHandle: pointer, # WINUSB_INTERFACE_HANDLE
AlternateSettingNumber: uint8, # BYTE
PipeIndex: uint8, # BYTE
PipeInformationEx: ptr WINUSB_PIPE_INFORMATION_EX # WINUSB_PIPE_INFORMATION_EX* out
): int32 {.importc: "WinUsb_QueryPipeEx", stdcall, dynlib: "WINUSB.dll".}pragma(lib, "winusb");
extern(Windows)
int WinUsb_QueryPipeEx(
void* InterfaceHandle, // WINUSB_INTERFACE_HANDLE
ubyte AlternateSettingNumber, // BYTE
ubyte PipeIndex, // BYTE
WINUSB_PIPE_INFORMATION_EX* PipeInformationEx // WINUSB_PIPE_INFORMATION_EX* out
);ccall((:WinUsb_QueryPipeEx, "WINUSB.dll"), stdcall, Int32,
(Ptr{Cvoid}, UInt8, UInt8, Ptr{WINUSB_PIPE_INFORMATION_EX}),
InterfaceHandle, AlternateSettingNumber, PipeIndex, PipeInformationEx)
# InterfaceHandle : WINUSB_INTERFACE_HANDLE -> Ptr{Cvoid}
# AlternateSettingNumber : BYTE -> UInt8
# PipeIndex : BYTE -> UInt8
# PipeInformationEx : WINUSB_PIPE_INFORMATION_EX* out -> Ptr{WINUSB_PIPE_INFORMATION_EX}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t WinUsb_QueryPipeEx(
void* InterfaceHandle,
uint8_t AlternateSettingNumber,
uint8_t PipeIndex,
void* PipeInformationEx);
]]
local winusb = ffi.load("winusb")
-- winusb.WinUsb_QueryPipeEx(InterfaceHandle, AlternateSettingNumber, PipeIndex, PipeInformationEx)
-- InterfaceHandle : WINUSB_INTERFACE_HANDLE
-- AlternateSettingNumber : BYTE
-- PipeIndex : BYTE
-- PipeInformationEx : WINUSB_PIPE_INFORMATION_EX* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('WINUSB.dll');
const WinUsb_QueryPipeEx = lib.func('__stdcall', 'WinUsb_QueryPipeEx', 'int32_t', ['void *', 'uint8_t', 'uint8_t', 'void *']);
// WinUsb_QueryPipeEx(InterfaceHandle, AlternateSettingNumber, PipeIndex, PipeInformationEx)
// InterfaceHandle : WINUSB_INTERFACE_HANDLE -> 'void *'
// AlternateSettingNumber : BYTE -> 'uint8_t'
// PipeIndex : BYTE -> 'uint8_t'
// PipeInformationEx : WINUSB_PIPE_INFORMATION_EX* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("WINUSB.dll", {
WinUsb_QueryPipeEx: { parameters: ["pointer", "u8", "u8", "pointer"], result: "i32" },
});
// lib.symbols.WinUsb_QueryPipeEx(InterfaceHandle, AlternateSettingNumber, PipeIndex, PipeInformationEx)
// InterfaceHandle : WINUSB_INTERFACE_HANDLE -> "pointer"
// AlternateSettingNumber : BYTE -> "u8"
// PipeIndex : BYTE -> "u8"
// PipeInformationEx : WINUSB_PIPE_INFORMATION_EX* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t WinUsb_QueryPipeEx(
void* InterfaceHandle,
uint8_t AlternateSettingNumber,
uint8_t PipeIndex,
void* PipeInformationEx);
C, "WINUSB.dll");
// $ffi->WinUsb_QueryPipeEx(InterfaceHandle, AlternateSettingNumber, PipeIndex, PipeInformationEx);
// InterfaceHandle : WINUSB_INTERFACE_HANDLE
// AlternateSettingNumber : BYTE
// PipeIndex : BYTE
// PipeInformationEx : WINUSB_PIPE_INFORMATION_EX* 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_QueryPipeEx(
Pointer InterfaceHandle, // WINUSB_INTERFACE_HANDLE
byte AlternateSettingNumber, // BYTE
byte PipeIndex, // BYTE
Pointer PipeInformationEx // WINUSB_PIPE_INFORMATION_EX* out
);
}@[Link("winusb")]
lib LibWINUSB
fun WinUsb_QueryPipeEx = WinUsb_QueryPipeEx(
InterfaceHandle : Void*, # WINUSB_INTERFACE_HANDLE
AlternateSettingNumber : UInt8, # BYTE
PipeIndex : UInt8, # BYTE
PipeInformationEx : WINUSB_PIPE_INFORMATION_EX* # WINUSB_PIPE_INFORMATION_EX* 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_QueryPipeExNative = Int32 Function(Pointer<Void>, Uint8, Uint8, Pointer<Void>);
typedef WinUsb_QueryPipeExDart = int Function(Pointer<Void>, int, int, Pointer<Void>);
final WinUsb_QueryPipeEx = DynamicLibrary.open('WINUSB.dll')
.lookupFunction<WinUsb_QueryPipeExNative, WinUsb_QueryPipeExDart>('WinUsb_QueryPipeEx');
// InterfaceHandle : WINUSB_INTERFACE_HANDLE -> Pointer<Void>
// AlternateSettingNumber : BYTE -> Uint8
// PipeIndex : BYTE -> Uint8
// PipeInformationEx : WINUSB_PIPE_INFORMATION_EX* out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WinUsb_QueryPipeEx"
c_WinUsb_QueryPipeEx :: Ptr () -> Word8 -> Word8 -> Ptr () -> IO CInt
-- InterfaceHandle : WINUSB_INTERFACE_HANDLE -> Ptr ()
-- AlternateSettingNumber : BYTE -> Word8
-- PipeIndex : BYTE -> Word8
-- PipeInformationEx : WINUSB_PIPE_INFORMATION_EX* out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let winusb_querypipeex =
foreign "WinUsb_QueryPipeEx"
((ptr void) @-> uint8_t @-> uint8_t @-> (ptr void) @-> returning int32_t)
(* InterfaceHandle : WINUSB_INTERFACE_HANDLE -> (ptr void) *)
(* AlternateSettingNumber : BYTE -> uint8_t *)
(* PipeIndex : BYTE -> uint8_t *)
(* PipeInformationEx : WINUSB_PIPE_INFORMATION_EX* 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_QueryPipeEx" win-usb-query-pipe-ex :convention :stdcall) :int32
(interface-handle :pointer) ; WINUSB_INTERFACE_HANDLE
(alternate-setting-number :uint8) ; BYTE
(pipe-index :uint8) ; BYTE
(pipe-information-ex :pointer)) ; WINUSB_PIPE_INFORMATION_EX* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $WinUsb_QueryPipeEx = Win32::API::More->new('WINUSB',
'BOOL WinUsb_QueryPipeEx(HANDLE InterfaceHandle, BYTE AlternateSettingNumber, BYTE PipeIndex, LPVOID PipeInformationEx)');
# my $ret = $WinUsb_QueryPipeEx->Call($InterfaceHandle, $AlternateSettingNumber, $PipeIndex, $PipeInformationEx);
# InterfaceHandle : WINUSB_INTERFACE_HANDLE -> HANDLE
# AlternateSettingNumber : BYTE -> BYTE
# PipeIndex : BYTE -> BYTE
# PipeInformationEx : WINUSB_PIPE_INFORMATION_EX* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
類似 API
- f WinUsb_QueryPipe — 指定したパイプのエンドポイント情報を取得する。