ホーム › Devices.DeviceAndDriverInstallation › SetupDiGetDevicePropertyKeys
SetupDiGetDevicePropertyKeys
関数デバイスが持つデバイスプロパティのキー一覧を取得する。
シグネチャ
// SETUPAPI.dll
#include <windows.h>
BOOL SetupDiGetDevicePropertyKeys(
HDEVINFO DeviceInfoSet,
SP_DEVINFO_DATA* DeviceInfoData,
DEVPROPKEY* PropertyKeyArray, // optional
DWORD PropertyKeyCount,
DWORD* RequiredPropertyKeyCount, // optional
DWORD Flags
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| DeviceInfoSet | HDEVINFO | in |
| DeviceInfoData | SP_DEVINFO_DATA* | in |
| PropertyKeyArray | DEVPROPKEY* | outoptional |
| PropertyKeyCount | DWORD | in |
| RequiredPropertyKeyCount | DWORD* | outoptional |
| Flags | DWORD | in |
戻り値の型: BOOL
各言語での呼び出し定義
// SETUPAPI.dll
#include <windows.h>
BOOL SetupDiGetDevicePropertyKeys(
HDEVINFO DeviceInfoSet,
SP_DEVINFO_DATA* DeviceInfoData,
DEVPROPKEY* PropertyKeyArray, // optional
DWORD PropertyKeyCount,
DWORD* RequiredPropertyKeyCount, // optional
DWORD Flags
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", SetLastError = true, ExactSpelling = true)]
static extern bool SetupDiGetDevicePropertyKeys(
IntPtr DeviceInfoSet, // HDEVINFO
IntPtr DeviceInfoData, // SP_DEVINFO_DATA*
IntPtr PropertyKeyArray, // DEVPROPKEY* optional, out
uint PropertyKeyCount, // DWORD
IntPtr RequiredPropertyKeyCount, // DWORD* optional, out
uint Flags // DWORD
);<DllImport("SETUPAPI.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupDiGetDevicePropertyKeys(
DeviceInfoSet As IntPtr, ' HDEVINFO
DeviceInfoData As IntPtr, ' SP_DEVINFO_DATA*
PropertyKeyArray As IntPtr, ' DEVPROPKEY* optional, out
PropertyKeyCount As UInteger, ' DWORD
RequiredPropertyKeyCount As IntPtr, ' DWORD* optional, out
Flags As UInteger ' DWORD
) As Boolean
End Function' DeviceInfoSet : HDEVINFO
' DeviceInfoData : SP_DEVINFO_DATA*
' PropertyKeyArray : DEVPROPKEY* optional, out
' PropertyKeyCount : DWORD
' RequiredPropertyKeyCount : DWORD* optional, out
' Flags : DWORD
Declare PtrSafe Function SetupDiGetDevicePropertyKeys Lib "setupapi" ( _
ByVal DeviceInfoSet As LongPtr, _
ByVal DeviceInfoData As LongPtr, _
ByVal PropertyKeyArray As LongPtr, _
ByVal PropertyKeyCount As Long, _
ByVal RequiredPropertyKeyCount As LongPtr, _
ByVal Flags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetupDiGetDevicePropertyKeys = ctypes.windll.setupapi.SetupDiGetDevicePropertyKeys
SetupDiGetDevicePropertyKeys.restype = wintypes.BOOL
SetupDiGetDevicePropertyKeys.argtypes = [
ctypes.c_ssize_t, # DeviceInfoSet : HDEVINFO
ctypes.c_void_p, # DeviceInfoData : SP_DEVINFO_DATA*
ctypes.c_void_p, # PropertyKeyArray : DEVPROPKEY* optional, out
wintypes.DWORD, # PropertyKeyCount : DWORD
ctypes.POINTER(wintypes.DWORD), # RequiredPropertyKeyCount : DWORD* optional, out
wintypes.DWORD, # Flags : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SETUPAPI.dll')
SetupDiGetDevicePropertyKeys = Fiddle::Function.new(
lib['SetupDiGetDevicePropertyKeys'],
[
Fiddle::TYPE_INTPTR_T, # DeviceInfoSet : HDEVINFO
Fiddle::TYPE_VOIDP, # DeviceInfoData : SP_DEVINFO_DATA*
Fiddle::TYPE_VOIDP, # PropertyKeyArray : DEVPROPKEY* optional, out
-Fiddle::TYPE_INT, # PropertyKeyCount : DWORD
Fiddle::TYPE_VOIDP, # RequiredPropertyKeyCount : DWORD* optional, out
-Fiddle::TYPE_INT, # Flags : DWORD
],
Fiddle::TYPE_INT)#[link(name = "setupapi")]
extern "system" {
fn SetupDiGetDevicePropertyKeys(
DeviceInfoSet: isize, // HDEVINFO
DeviceInfoData: *mut SP_DEVINFO_DATA, // SP_DEVINFO_DATA*
PropertyKeyArray: *mut DEVPROPKEY, // DEVPROPKEY* optional, out
PropertyKeyCount: u32, // DWORD
RequiredPropertyKeyCount: *mut u32, // DWORD* optional, out
Flags: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", SetLastError = true)]
public static extern bool SetupDiGetDevicePropertyKeys(IntPtr DeviceInfoSet, IntPtr DeviceInfoData, IntPtr PropertyKeyArray, uint PropertyKeyCount, IntPtr RequiredPropertyKeyCount, uint Flags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupDiGetDevicePropertyKeys' -Namespace Win32 -PassThru
# $api::SetupDiGetDevicePropertyKeys(DeviceInfoSet, DeviceInfoData, PropertyKeyArray, PropertyKeyCount, RequiredPropertyKeyCount, Flags)#uselib "SETUPAPI.dll"
#func global SetupDiGetDevicePropertyKeys "SetupDiGetDevicePropertyKeys" sptr, sptr, sptr, sptr, sptr, sptr
; SetupDiGetDevicePropertyKeys DeviceInfoSet, varptr(DeviceInfoData), varptr(PropertyKeyArray), PropertyKeyCount, varptr(RequiredPropertyKeyCount), Flags ; 戻り値は stat
; DeviceInfoSet : HDEVINFO -> "sptr"
; DeviceInfoData : SP_DEVINFO_DATA* -> "sptr"
; PropertyKeyArray : DEVPROPKEY* optional, out -> "sptr"
; PropertyKeyCount : DWORD -> "sptr"
; RequiredPropertyKeyCount : DWORD* optional, out -> "sptr"
; Flags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SETUPAPI.dll" #cfunc global SetupDiGetDevicePropertyKeys "SetupDiGetDevicePropertyKeys" sptr, var, var, int, var, int ; res = SetupDiGetDevicePropertyKeys(DeviceInfoSet, DeviceInfoData, PropertyKeyArray, PropertyKeyCount, RequiredPropertyKeyCount, Flags) ; DeviceInfoSet : HDEVINFO -> "sptr" ; DeviceInfoData : SP_DEVINFO_DATA* -> "var" ; PropertyKeyArray : DEVPROPKEY* optional, out -> "var" ; PropertyKeyCount : DWORD -> "int" ; RequiredPropertyKeyCount : DWORD* optional, out -> "var" ; Flags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SETUPAPI.dll" #cfunc global SetupDiGetDevicePropertyKeys "SetupDiGetDevicePropertyKeys" sptr, sptr, sptr, int, sptr, int ; res = SetupDiGetDevicePropertyKeys(DeviceInfoSet, varptr(DeviceInfoData), varptr(PropertyKeyArray), PropertyKeyCount, varptr(RequiredPropertyKeyCount), Flags) ; DeviceInfoSet : HDEVINFO -> "sptr" ; DeviceInfoData : SP_DEVINFO_DATA* -> "sptr" ; PropertyKeyArray : DEVPROPKEY* optional, out -> "sptr" ; PropertyKeyCount : DWORD -> "int" ; RequiredPropertyKeyCount : DWORD* optional, out -> "sptr" ; Flags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL SetupDiGetDevicePropertyKeys(HDEVINFO DeviceInfoSet, SP_DEVINFO_DATA* DeviceInfoData, DEVPROPKEY* PropertyKeyArray, DWORD PropertyKeyCount, DWORD* RequiredPropertyKeyCount, DWORD Flags) #uselib "SETUPAPI.dll" #cfunc global SetupDiGetDevicePropertyKeys "SetupDiGetDevicePropertyKeys" intptr, var, var, int, var, int ; res = SetupDiGetDevicePropertyKeys(DeviceInfoSet, DeviceInfoData, PropertyKeyArray, PropertyKeyCount, RequiredPropertyKeyCount, Flags) ; DeviceInfoSet : HDEVINFO -> "intptr" ; DeviceInfoData : SP_DEVINFO_DATA* -> "var" ; PropertyKeyArray : DEVPROPKEY* optional, out -> "var" ; PropertyKeyCount : DWORD -> "int" ; RequiredPropertyKeyCount : DWORD* optional, out -> "var" ; Flags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL SetupDiGetDevicePropertyKeys(HDEVINFO DeviceInfoSet, SP_DEVINFO_DATA* DeviceInfoData, DEVPROPKEY* PropertyKeyArray, DWORD PropertyKeyCount, DWORD* RequiredPropertyKeyCount, DWORD Flags) #uselib "SETUPAPI.dll" #cfunc global SetupDiGetDevicePropertyKeys "SetupDiGetDevicePropertyKeys" intptr, intptr, intptr, int, intptr, int ; res = SetupDiGetDevicePropertyKeys(DeviceInfoSet, varptr(DeviceInfoData), varptr(PropertyKeyArray), PropertyKeyCount, varptr(RequiredPropertyKeyCount), Flags) ; DeviceInfoSet : HDEVINFO -> "intptr" ; DeviceInfoData : SP_DEVINFO_DATA* -> "intptr" ; PropertyKeyArray : DEVPROPKEY* optional, out -> "intptr" ; PropertyKeyCount : DWORD -> "int" ; RequiredPropertyKeyCount : DWORD* optional, out -> "intptr" ; Flags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
procSetupDiGetDevicePropertyKeys = setupapi.NewProc("SetupDiGetDevicePropertyKeys")
)
// DeviceInfoSet (HDEVINFO), DeviceInfoData (SP_DEVINFO_DATA*), PropertyKeyArray (DEVPROPKEY* optional, out), PropertyKeyCount (DWORD), RequiredPropertyKeyCount (DWORD* optional, out), Flags (DWORD)
r1, _, err := procSetupDiGetDevicePropertyKeys.Call(
uintptr(DeviceInfoSet),
uintptr(DeviceInfoData),
uintptr(PropertyKeyArray),
uintptr(PropertyKeyCount),
uintptr(RequiredPropertyKeyCount),
uintptr(Flags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetupDiGetDevicePropertyKeys(
DeviceInfoSet: NativeInt; // HDEVINFO
DeviceInfoData: Pointer; // SP_DEVINFO_DATA*
PropertyKeyArray: Pointer; // DEVPROPKEY* optional, out
PropertyKeyCount: DWORD; // DWORD
RequiredPropertyKeyCount: Pointer; // DWORD* optional, out
Flags: DWORD // DWORD
): BOOL; stdcall;
external 'SETUPAPI.dll' name 'SetupDiGetDevicePropertyKeys';result := DllCall("SETUPAPI\SetupDiGetDevicePropertyKeys"
, "Ptr", DeviceInfoSet ; HDEVINFO
, "Ptr", DeviceInfoData ; SP_DEVINFO_DATA*
, "Ptr", PropertyKeyArray ; DEVPROPKEY* optional, out
, "UInt", PropertyKeyCount ; DWORD
, "Ptr", RequiredPropertyKeyCount ; DWORD* optional, out
, "UInt", Flags ; DWORD
, "Int") ; return: BOOL●SetupDiGetDevicePropertyKeys(DeviceInfoSet, DeviceInfoData, PropertyKeyArray, PropertyKeyCount, RequiredPropertyKeyCount, Flags) = DLL("SETUPAPI.dll", "bool SetupDiGetDevicePropertyKeys(int, void*, void*, dword, void*, dword)")
# 呼び出し: SetupDiGetDevicePropertyKeys(DeviceInfoSet, DeviceInfoData, PropertyKeyArray, PropertyKeyCount, RequiredPropertyKeyCount, Flags)
# DeviceInfoSet : HDEVINFO -> "int"
# DeviceInfoData : SP_DEVINFO_DATA* -> "void*"
# PropertyKeyArray : DEVPROPKEY* optional, out -> "void*"
# PropertyKeyCount : DWORD -> "dword"
# RequiredPropertyKeyCount : DWORD* optional, out -> "void*"
# Flags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。