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