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