ホーム › 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 | 設定するプロパティの種別。SPDRP_*のSETUP_DI_REGISTRY_PROPERTY値を指定する。 |
| PropertyBuffer | BYTE* | inoptional | 設定する値を格納したバッファ(Unicode)。プロパティ削除時はNULL可。 |
| PropertyBufferSize | DWORD | in | PropertyBufferのバイトサイズ。削除時は0。 |
戻り値の型: 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 <MarshalAs(UnmanagedType.Bool)> 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 版の利用を推奨。const std = @import("std");
extern "setupapi" fn SetupDiSetDeviceRegistryPropertyW(
DeviceInfoSet: isize, // HDEVINFO
DeviceInfoData: [*c]SP_DEVINFO_DATA, // SP_DEVINFO_DATA* in/out
Property: u32, // SETUP_DI_REGISTRY_PROPERTY
PropertyBuffer: [*c]u8, // BYTE* optional
PropertyBufferSize: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc SetupDiSetDeviceRegistryPropertyW(
DeviceInfoSet: int, # HDEVINFO
DeviceInfoData: ptr SP_DEVINFO_DATA, # SP_DEVINFO_DATA* in/out
Property: uint32, # SETUP_DI_REGISTRY_PROPERTY
PropertyBuffer: ptr uint8, # BYTE* optional
PropertyBufferSize: uint32 # DWORD
): int32 {.importc: "SetupDiSetDeviceRegistryPropertyW", stdcall, dynlib: "SETUPAPI.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "setupapi");
extern(Windows)
int SetupDiSetDeviceRegistryPropertyW(
ptrdiff_t DeviceInfoSet, // HDEVINFO
SP_DEVINFO_DATA* DeviceInfoData, // SP_DEVINFO_DATA* in/out
uint Property, // SETUP_DI_REGISTRY_PROPERTY
ubyte* PropertyBuffer, // BYTE* optional
uint PropertyBufferSize // DWORD
);ccall((:SetupDiSetDeviceRegistryPropertyW, "SETUPAPI.dll"), stdcall, Int32,
(Int, Ptr{SP_DEVINFO_DATA}, UInt32, Ptr{UInt8}, UInt32),
DeviceInfoSet, DeviceInfoData, Property, PropertyBuffer, PropertyBufferSize)
# DeviceInfoSet : HDEVINFO -> Int
# DeviceInfoData : SP_DEVINFO_DATA* in/out -> Ptr{SP_DEVINFO_DATA}
# Property : SETUP_DI_REGISTRY_PROPERTY -> UInt32
# PropertyBuffer : BYTE* optional -> Ptr{UInt8}
# PropertyBufferSize : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
int32_t SetupDiSetDeviceRegistryPropertyW(
intptr_t DeviceInfoSet,
void* DeviceInfoData,
uint32_t Property,
uint8_t* PropertyBuffer,
uint32_t PropertyBufferSize);
]]
local setupapi = ffi.load("setupapi")
-- setupapi.SetupDiSetDeviceRegistryPropertyW(DeviceInfoSet, DeviceInfoData, Property, PropertyBuffer, PropertyBufferSize)
-- DeviceInfoSet : HDEVINFO
-- DeviceInfoData : SP_DEVINFO_DATA* in/out
-- Property : SETUP_DI_REGISTRY_PROPERTY
-- PropertyBuffer : BYTE* optional
-- PropertyBufferSize : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('SETUPAPI.dll');
const SetupDiSetDeviceRegistryPropertyW = lib.func('__stdcall', 'SetupDiSetDeviceRegistryPropertyW', 'int32_t', ['intptr_t', 'void *', 'uint32_t', 'uint8_t *', 'uint32_t']);
// SetupDiSetDeviceRegistryPropertyW(DeviceInfoSet, DeviceInfoData, Property, PropertyBuffer, PropertyBufferSize)
// DeviceInfoSet : HDEVINFO -> 'intptr_t'
// DeviceInfoData : SP_DEVINFO_DATA* in/out -> 'void *'
// Property : SETUP_DI_REGISTRY_PROPERTY -> 'uint32_t'
// PropertyBuffer : BYTE* optional -> 'uint8_t *'
// PropertyBufferSize : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("SETUPAPI.dll", {
SetupDiSetDeviceRegistryPropertyW: { parameters: ["isize", "pointer", "u32", "pointer", "u32"], result: "i32" },
});
// lib.symbols.SetupDiSetDeviceRegistryPropertyW(DeviceInfoSet, DeviceInfoData, Property, PropertyBuffer, PropertyBufferSize)
// DeviceInfoSet : HDEVINFO -> "isize"
// DeviceInfoData : SP_DEVINFO_DATA* in/out -> "pointer"
// Property : SETUP_DI_REGISTRY_PROPERTY -> "u32"
// PropertyBuffer : BYTE* optional -> "pointer"
// PropertyBufferSize : DWORD -> "u32"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t SetupDiSetDeviceRegistryPropertyW(
intptr_t DeviceInfoSet,
void* DeviceInfoData,
uint32_t Property,
uint8_t* PropertyBuffer,
uint32_t PropertyBufferSize);
C, "SETUPAPI.dll");
// $ffi->SetupDiSetDeviceRegistryPropertyW(DeviceInfoSet, DeviceInfoData, Property, PropertyBuffer, PropertyBufferSize);
// DeviceInfoSet : HDEVINFO
// DeviceInfoData : SP_DEVINFO_DATA* in/out
// Property : SETUP_DI_REGISTRY_PROPERTY
// PropertyBuffer : BYTE* optional
// PropertyBufferSize : DWORD
// 構造体/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 Setupapi extends StdCallLibrary {
Setupapi INSTANCE = Native.load("setupapi", Setupapi.class, W32APIOptions.UNICODE_OPTIONS);
boolean SetupDiSetDeviceRegistryPropertyW(
long DeviceInfoSet, // HDEVINFO
Pointer DeviceInfoData, // SP_DEVINFO_DATA* in/out
int Property, // SETUP_DI_REGISTRY_PROPERTY
byte[] PropertyBuffer, // BYTE* optional
int PropertyBufferSize // DWORD
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("setupapi")]
lib LibSETUPAPI
fun SetupDiSetDeviceRegistryPropertyW = SetupDiSetDeviceRegistryPropertyW(
DeviceInfoSet : LibC::SSizeT, # HDEVINFO
DeviceInfoData : SP_DEVINFO_DATA*, # SP_DEVINFO_DATA* in/out
Property : UInt32, # SETUP_DI_REGISTRY_PROPERTY
PropertyBuffer : UInt8*, # BYTE* optional
PropertyBufferSize : UInt32 # DWORD
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SetupDiSetDeviceRegistryPropertyWNative = Int32 Function(IntPtr, Pointer<Void>, Uint32, Pointer<Uint8>, Uint32);
typedef SetupDiSetDeviceRegistryPropertyWDart = int Function(int, Pointer<Void>, int, Pointer<Uint8>, int);
final SetupDiSetDeviceRegistryPropertyW = DynamicLibrary.open('SETUPAPI.dll')
.lookupFunction<SetupDiSetDeviceRegistryPropertyWNative, SetupDiSetDeviceRegistryPropertyWDart>('SetupDiSetDeviceRegistryPropertyW');
// DeviceInfoSet : HDEVINFO -> IntPtr
// DeviceInfoData : SP_DEVINFO_DATA* in/out -> Pointer<Void>
// Property : SETUP_DI_REGISTRY_PROPERTY -> Uint32
// PropertyBuffer : BYTE* optional -> Pointer<Uint8>
// PropertyBufferSize : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function 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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SetupDiSetDeviceRegistryPropertyW"
c_SetupDiSetDeviceRegistryPropertyW :: CIntPtr -> Ptr () -> Word32 -> Ptr Word8 -> Word32 -> IO CInt
-- DeviceInfoSet : HDEVINFO -> CIntPtr
-- DeviceInfoData : SP_DEVINFO_DATA* in/out -> Ptr ()
-- Property : SETUP_DI_REGISTRY_PROPERTY -> Word32
-- PropertyBuffer : BYTE* optional -> Ptr Word8
-- PropertyBufferSize : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let setupdisetdeviceregistrypropertyw =
foreign "SetupDiSetDeviceRegistryPropertyW"
(intptr_t @-> (ptr void) @-> uint32_t @-> (ptr uint8_t) @-> uint32_t @-> returning int32_t)
(* DeviceInfoSet : HDEVINFO -> intptr_t *)
(* DeviceInfoData : SP_DEVINFO_DATA* in/out -> (ptr void) *)
(* Property : SETUP_DI_REGISTRY_PROPERTY -> uint32_t *)
(* PropertyBuffer : BYTE* optional -> (ptr uint8_t) *)
(* PropertyBufferSize : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library setupapi (t "SETUPAPI.dll"))
(cffi:use-foreign-library setupapi)
(cffi:defcfun ("SetupDiSetDeviceRegistryPropertyW" setup-di-set-device-registry-property-w :convention :stdcall) :int32
(device-info-set :int64) ; HDEVINFO
(device-info-data :pointer) ; SP_DEVINFO_DATA* in/out
(property :uint32) ; SETUP_DI_REGISTRY_PROPERTY
(property-buffer :pointer) ; BYTE* optional
(property-buffer-size :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SetupDiSetDeviceRegistryPropertyW = Win32::API::More->new('SETUPAPI',
'BOOL SetupDiSetDeviceRegistryPropertyW(LPARAM DeviceInfoSet, LPVOID DeviceInfoData, DWORD Property, LPVOID PropertyBuffer, DWORD PropertyBufferSize)');
# my $ret = $SetupDiSetDeviceRegistryPropertyW->Call($DeviceInfoSet, $DeviceInfoData, $Property, $PropertyBuffer, $PropertyBufferSize);
# DeviceInfoSet : HDEVINFO -> LPARAM
# DeviceInfoData : SP_DEVINFO_DATA* in/out -> LPVOID
# Property : SETUP_DI_REGISTRY_PROPERTY -> DWORD
# PropertyBuffer : BYTE* optional -> LPVOID
# PropertyBufferSize : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f SetupDiSetDeviceRegistryPropertyA (ANSI版) — 指定デバイスのレジストリプロパティ値を設定する。