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

HidP_GetLinkCollectionNodes

関数
HIDデバイスのリンクコレクションノード一覧を取得する。
DLLHID.dll呼出規約winapi

シグネチャ

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

NTSTATUS HidP_GetLinkCollectionNodes(
    HIDP_LINK_COLLECTION_NODE* LinkCollectionNodes,
    DWORD* LinkCollectionNodesLength,
    PHIDP_PREPARSED_DATA PreparsedData
);

パラメーター

名前方向説明
LinkCollectionNodesHIDP_LINK_COLLECTION_NODE*outリンクコレクションノード配列(HIDP_LINK_COLLECTION_NODE)を受け取るバッファへのポインタを指定する。
LinkCollectionNodesLengthDWORD*inout入出力で配列の容量を指定し、実際のノード数を受け取るDWORDへのポインタを指定する。
PreparsedDataPHIDP_PREPARSED_DATAinHidD_GetPreparsedDataで取得した前解析データへのポインタを指定する。

戻り値の型: NTSTATUS

各言語での呼び出し定義

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

NTSTATUS HidP_GetLinkCollectionNodes(
    HIDP_LINK_COLLECTION_NODE* LinkCollectionNodes,
    DWORD* LinkCollectionNodesLength,
    PHIDP_PREPARSED_DATA PreparsedData
);
[DllImport("HID.dll", ExactSpelling = true)]
static extern int HidP_GetLinkCollectionNodes(
    IntPtr LinkCollectionNodes,   // HIDP_LINK_COLLECTION_NODE* out
    ref uint LinkCollectionNodesLength,   // DWORD* in/out
    IntPtr PreparsedData   // PHIDP_PREPARSED_DATA
);
<DllImport("HID.dll", ExactSpelling:=True)>
Public Shared Function HidP_GetLinkCollectionNodes(
    LinkCollectionNodes As IntPtr,   ' HIDP_LINK_COLLECTION_NODE* out
    ByRef LinkCollectionNodesLength As UInteger,   ' DWORD* in/out
    PreparsedData As IntPtr   ' PHIDP_PREPARSED_DATA
) As Integer
End Function
' LinkCollectionNodes : HIDP_LINK_COLLECTION_NODE* out
' LinkCollectionNodesLength : DWORD* in/out
' PreparsedData : PHIDP_PREPARSED_DATA
Declare PtrSafe Function HidP_GetLinkCollectionNodes Lib "hid" ( _
    ByVal LinkCollectionNodes As LongPtr, _
    ByRef LinkCollectionNodesLength As Long, _
    ByVal PreparsedData As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

HidP_GetLinkCollectionNodes = ctypes.windll.hid.HidP_GetLinkCollectionNodes
HidP_GetLinkCollectionNodes.restype = ctypes.c_int
HidP_GetLinkCollectionNodes.argtypes = [
    ctypes.c_void_p,  # LinkCollectionNodes : HIDP_LINK_COLLECTION_NODE* out
    ctypes.POINTER(wintypes.DWORD),  # LinkCollectionNodesLength : DWORD* in/out
    ctypes.c_ssize_t,  # PreparsedData : PHIDP_PREPARSED_DATA
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('HID.dll')
HidP_GetLinkCollectionNodes = Fiddle::Function.new(
  lib['HidP_GetLinkCollectionNodes'],
  [
    Fiddle::TYPE_VOIDP,  # LinkCollectionNodes : HIDP_LINK_COLLECTION_NODE* out
    Fiddle::TYPE_VOIDP,  # LinkCollectionNodesLength : DWORD* in/out
    Fiddle::TYPE_INTPTR_T,  # PreparsedData : PHIDP_PREPARSED_DATA
  ],
  Fiddle::TYPE_INT)
#[link(name = "hid")]
extern "system" {
    fn HidP_GetLinkCollectionNodes(
        LinkCollectionNodes: *mut HIDP_LINK_COLLECTION_NODE,  // HIDP_LINK_COLLECTION_NODE* out
        LinkCollectionNodesLength: *mut u32,  // DWORD* in/out
        PreparsedData: isize  // PHIDP_PREPARSED_DATA
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("HID.dll")]
public static extern int HidP_GetLinkCollectionNodes(IntPtr LinkCollectionNodes, ref uint LinkCollectionNodesLength, IntPtr PreparsedData);
"@
$api = Add-Type -MemberDefinition $sig -Name 'HID_HidP_GetLinkCollectionNodes' -Namespace Win32 -PassThru
# $api::HidP_GetLinkCollectionNodes(LinkCollectionNodes, LinkCollectionNodesLength, PreparsedData)
#uselib "HID.dll"
#func global HidP_GetLinkCollectionNodes "HidP_GetLinkCollectionNodes" sptr, sptr, sptr
; HidP_GetLinkCollectionNodes varptr(LinkCollectionNodes), varptr(LinkCollectionNodesLength), PreparsedData   ; 戻り値は stat
; LinkCollectionNodes : HIDP_LINK_COLLECTION_NODE* out -> "sptr"
; LinkCollectionNodesLength : DWORD* in/out -> "sptr"
; PreparsedData : PHIDP_PREPARSED_DATA -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "HID.dll"
#cfunc global HidP_GetLinkCollectionNodes "HidP_GetLinkCollectionNodes" var, var, sptr
; res = HidP_GetLinkCollectionNodes(LinkCollectionNodes, LinkCollectionNodesLength, PreparsedData)
; LinkCollectionNodes : HIDP_LINK_COLLECTION_NODE* out -> "var"
; LinkCollectionNodesLength : DWORD* in/out -> "var"
; PreparsedData : PHIDP_PREPARSED_DATA -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; NTSTATUS HidP_GetLinkCollectionNodes(HIDP_LINK_COLLECTION_NODE* LinkCollectionNodes, DWORD* LinkCollectionNodesLength, PHIDP_PREPARSED_DATA PreparsedData)
#uselib "HID.dll"
#cfunc global HidP_GetLinkCollectionNodes "HidP_GetLinkCollectionNodes" var, var, intptr
; res = HidP_GetLinkCollectionNodes(LinkCollectionNodes, LinkCollectionNodesLength, PreparsedData)
; LinkCollectionNodes : HIDP_LINK_COLLECTION_NODE* out -> "var"
; LinkCollectionNodesLength : DWORD* in/out -> "var"
; PreparsedData : PHIDP_PREPARSED_DATA -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	hid = windows.NewLazySystemDLL("HID.dll")
	procHidP_GetLinkCollectionNodes = hid.NewProc("HidP_GetLinkCollectionNodes")
)

// LinkCollectionNodes (HIDP_LINK_COLLECTION_NODE* out), LinkCollectionNodesLength (DWORD* in/out), PreparsedData (PHIDP_PREPARSED_DATA)
r1, _, err := procHidP_GetLinkCollectionNodes.Call(
	uintptr(LinkCollectionNodes),
	uintptr(LinkCollectionNodesLength),
	uintptr(PreparsedData),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // NTSTATUS
function HidP_GetLinkCollectionNodes(
  LinkCollectionNodes: Pointer;   // HIDP_LINK_COLLECTION_NODE* out
  LinkCollectionNodesLength: Pointer;   // DWORD* in/out
  PreparsedData: NativeInt   // PHIDP_PREPARSED_DATA
): Integer; stdcall;
  external 'HID.dll' name 'HidP_GetLinkCollectionNodes';
result := DllCall("HID\HidP_GetLinkCollectionNodes"
    , "Ptr", LinkCollectionNodes   ; HIDP_LINK_COLLECTION_NODE* out
    , "Ptr", LinkCollectionNodesLength   ; DWORD* in/out
    , "Ptr", PreparsedData   ; PHIDP_PREPARSED_DATA
    , "Int")   ; return: NTSTATUS
●HidP_GetLinkCollectionNodes(LinkCollectionNodes, LinkCollectionNodesLength, PreparsedData) = DLL("HID.dll", "int HidP_GetLinkCollectionNodes(void*, void*, int)")
# 呼び出し: HidP_GetLinkCollectionNodes(LinkCollectionNodes, LinkCollectionNodesLength, PreparsedData)
# LinkCollectionNodes : HIDP_LINK_COLLECTION_NODE* out -> "void*"
# LinkCollectionNodesLength : DWORD* in/out -> "void*"
# PreparsedData : PHIDP_PREPARSED_DATA -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "hid" fn HidP_GetLinkCollectionNodes(
    LinkCollectionNodes: [*c]HIDP_LINK_COLLECTION_NODE, // HIDP_LINK_COLLECTION_NODE* out
    LinkCollectionNodesLength: [*c]u32, // DWORD* in/out
    PreparsedData: isize // PHIDP_PREPARSED_DATA
) callconv(std.os.windows.WINAPI) i32;
proc HidP_GetLinkCollectionNodes(
    LinkCollectionNodes: ptr HIDP_LINK_COLLECTION_NODE,  # HIDP_LINK_COLLECTION_NODE* out
    LinkCollectionNodesLength: ptr uint32,  # DWORD* in/out
    PreparsedData: int  # PHIDP_PREPARSED_DATA
): int32 {.importc: "HidP_GetLinkCollectionNodes", stdcall, dynlib: "HID.dll".}
pragma(lib, "hid");
extern(Windows)
int HidP_GetLinkCollectionNodes(
    HIDP_LINK_COLLECTION_NODE* LinkCollectionNodes,   // HIDP_LINK_COLLECTION_NODE* out
    uint* LinkCollectionNodesLength,   // DWORD* in/out
    ptrdiff_t PreparsedData   // PHIDP_PREPARSED_DATA
);
ccall((:HidP_GetLinkCollectionNodes, "HID.dll"), stdcall, Int32,
      (Ptr{HIDP_LINK_COLLECTION_NODE}, Ptr{UInt32}, Int),
      LinkCollectionNodes, LinkCollectionNodesLength, PreparsedData)
# LinkCollectionNodes : HIDP_LINK_COLLECTION_NODE* out -> Ptr{HIDP_LINK_COLLECTION_NODE}
# LinkCollectionNodesLength : DWORD* in/out -> Ptr{UInt32}
# PreparsedData : PHIDP_PREPARSED_DATA -> Int
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t HidP_GetLinkCollectionNodes(
    void* LinkCollectionNodes,
    uint32_t* LinkCollectionNodesLength,
    intptr_t PreparsedData);
]]
local hid = ffi.load("hid")
-- hid.HidP_GetLinkCollectionNodes(LinkCollectionNodes, LinkCollectionNodesLength, PreparsedData)
-- LinkCollectionNodes : HIDP_LINK_COLLECTION_NODE* out
-- LinkCollectionNodesLength : DWORD* in/out
-- PreparsedData : PHIDP_PREPARSED_DATA
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('HID.dll');
const HidP_GetLinkCollectionNodes = lib.func('__stdcall', 'HidP_GetLinkCollectionNodes', 'int32_t', ['void *', 'uint32_t *', 'intptr_t']);
// HidP_GetLinkCollectionNodes(LinkCollectionNodes, LinkCollectionNodesLength, PreparsedData)
// LinkCollectionNodes : HIDP_LINK_COLLECTION_NODE* out -> 'void *'
// LinkCollectionNodesLength : DWORD* in/out -> 'uint32_t *'
// PreparsedData : PHIDP_PREPARSED_DATA -> 'intptr_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("HID.dll", {
  HidP_GetLinkCollectionNodes: { parameters: ["pointer", "pointer", "isize"], result: "i32" },
});
// lib.symbols.HidP_GetLinkCollectionNodes(LinkCollectionNodes, LinkCollectionNodesLength, PreparsedData)
// LinkCollectionNodes : HIDP_LINK_COLLECTION_NODE* out -> "pointer"
// LinkCollectionNodesLength : DWORD* in/out -> "pointer"
// PreparsedData : PHIDP_PREPARSED_DATA -> "isize"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t HidP_GetLinkCollectionNodes(
    void* LinkCollectionNodes,
    uint32_t* LinkCollectionNodesLength,
    intptr_t PreparsedData);
C, "HID.dll");
// $ffi->HidP_GetLinkCollectionNodes(LinkCollectionNodes, LinkCollectionNodesLength, PreparsedData);
// LinkCollectionNodes : HIDP_LINK_COLLECTION_NODE* out
// LinkCollectionNodesLength : DWORD* in/out
// PreparsedData : PHIDP_PREPARSED_DATA
// 構造体/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 Hid extends StdCallLibrary {
    Hid INSTANCE = Native.load("hid", Hid.class);
    int HidP_GetLinkCollectionNodes(
        Pointer LinkCollectionNodes,   // HIDP_LINK_COLLECTION_NODE* out
        IntByReference LinkCollectionNodesLength,   // DWORD* in/out
        long PreparsedData   // PHIDP_PREPARSED_DATA
    );
}
@[Link("hid")]
lib LibHID
  fun HidP_GetLinkCollectionNodes = HidP_GetLinkCollectionNodes(
    LinkCollectionNodes : HIDP_LINK_COLLECTION_NODE*,   # HIDP_LINK_COLLECTION_NODE* out
    LinkCollectionNodesLength : UInt32*,   # DWORD* in/out
    PreparsedData : LibC::SSizeT   # PHIDP_PREPARSED_DATA
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef HidP_GetLinkCollectionNodesNative = Int32 Function(Pointer<Void>, Pointer<Uint32>, IntPtr);
typedef HidP_GetLinkCollectionNodesDart = int Function(Pointer<Void>, Pointer<Uint32>, int);
final HidP_GetLinkCollectionNodes = DynamicLibrary.open('HID.dll')
    .lookupFunction<HidP_GetLinkCollectionNodesNative, HidP_GetLinkCollectionNodesDart>('HidP_GetLinkCollectionNodes');
// LinkCollectionNodes : HIDP_LINK_COLLECTION_NODE* out -> Pointer<Void>
// LinkCollectionNodesLength : DWORD* in/out -> Pointer<Uint32>
// PreparsedData : PHIDP_PREPARSED_DATA -> IntPtr
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function HidP_GetLinkCollectionNodes(
  LinkCollectionNodes: Pointer;   // HIDP_LINK_COLLECTION_NODE* out
  LinkCollectionNodesLength: Pointer;   // DWORD* in/out
  PreparsedData: NativeInt   // PHIDP_PREPARSED_DATA
): Integer; stdcall;
  external 'HID.dll' name 'HidP_GetLinkCollectionNodes';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "HidP_GetLinkCollectionNodes"
  c_HidP_GetLinkCollectionNodes :: Ptr () -> Ptr Word32 -> CIntPtr -> IO Int32
-- LinkCollectionNodes : HIDP_LINK_COLLECTION_NODE* out -> Ptr ()
-- LinkCollectionNodesLength : DWORD* in/out -> Ptr Word32
-- PreparsedData : PHIDP_PREPARSED_DATA -> CIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let hidp_getlinkcollectionnodes =
  foreign "HidP_GetLinkCollectionNodes"
    ((ptr void) @-> (ptr uint32_t) @-> intptr_t @-> returning int32_t)
(* LinkCollectionNodes : HIDP_LINK_COLLECTION_NODE* out -> (ptr void) *)
(* LinkCollectionNodesLength : DWORD* in/out -> (ptr uint32_t) *)
(* PreparsedData : PHIDP_PREPARSED_DATA -> intptr_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library hid (t "HID.dll"))
(cffi:use-foreign-library hid)

(cffi:defcfun ("HidP_GetLinkCollectionNodes" hid-p-get-link-collection-nodes :convention :stdcall) :int32
  (link-collection-nodes :pointer)   ; HIDP_LINK_COLLECTION_NODE* out
  (link-collection-nodes-length :pointer)   ; DWORD* in/out
  (preparsed-data :int64))   ; PHIDP_PREPARSED_DATA
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $HidP_GetLinkCollectionNodes = Win32::API::More->new('HID',
    'int HidP_GetLinkCollectionNodes(LPVOID LinkCollectionNodes, LPVOID LinkCollectionNodesLength, LPARAM PreparsedData)');
# my $ret = $HidP_GetLinkCollectionNodes->Call($LinkCollectionNodes, $LinkCollectionNodesLength, $PreparsedData);
# LinkCollectionNodes : HIDP_LINK_COLLECTION_NODE* out -> LPVOID
# LinkCollectionNodesLength : DWORD* in/out -> LPVOID
# PreparsedData : PHIDP_PREPARSED_DATA -> LPARAM
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型