ホーム › Devices.DeviceAndDriverInstallation › SetupDiSetClassPropertyW
SetupDiSetClassPropertyW
関数デバイスクラスの指定プロパティ値を設定する。
シグネチャ
// SETUPAPI.dll
#include <windows.h>
BOOL SetupDiSetClassPropertyW(
const GUID* ClassGuid,
const DEVPROPKEY* PropertyKey,
DEVPROPTYPE PropertyType,
const BYTE* PropertyBuffer, // optional
DWORD PropertyBufferSize,
DWORD Flags
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| ClassGuid | GUID* | in |
| PropertyKey | DEVPROPKEY* | in |
| PropertyType | DEVPROPTYPE | in |
| PropertyBuffer | BYTE* | inoptional |
| PropertyBufferSize | DWORD | in |
| Flags | DWORD | in |
戻り値の型: BOOL
各言語での呼び出し定義
// SETUPAPI.dll
#include <windows.h>
BOOL SetupDiSetClassPropertyW(
const GUID* ClassGuid,
const DEVPROPKEY* PropertyKey,
DEVPROPTYPE PropertyType,
const BYTE* PropertyBuffer, // optional
DWORD PropertyBufferSize,
DWORD Flags
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", SetLastError = true, ExactSpelling = true)]
static extern bool SetupDiSetClassPropertyW(
ref Guid ClassGuid, // GUID*
IntPtr PropertyKey, // DEVPROPKEY*
uint PropertyType, // DEVPROPTYPE
IntPtr PropertyBuffer, // BYTE* optional
uint PropertyBufferSize, // DWORD
uint Flags // DWORD
);<DllImport("SETUPAPI.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupDiSetClassPropertyW(
ByRef ClassGuid As Guid, ' GUID*
PropertyKey As IntPtr, ' DEVPROPKEY*
PropertyType As UInteger, ' DEVPROPTYPE
PropertyBuffer As IntPtr, ' BYTE* optional
PropertyBufferSize As UInteger, ' DWORD
Flags As UInteger ' DWORD
) As Boolean
End Function' ClassGuid : GUID*
' PropertyKey : DEVPROPKEY*
' PropertyType : DEVPROPTYPE
' PropertyBuffer : BYTE* optional
' PropertyBufferSize : DWORD
' Flags : DWORD
Declare PtrSafe Function SetupDiSetClassPropertyW Lib "setupapi" ( _
ByVal ClassGuid As LongPtr, _
ByVal PropertyKey As LongPtr, _
ByVal PropertyType As Long, _
ByVal PropertyBuffer As LongPtr, _
ByVal PropertyBufferSize As Long, _
ByVal Flags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetupDiSetClassPropertyW = ctypes.windll.setupapi.SetupDiSetClassPropertyW
SetupDiSetClassPropertyW.restype = wintypes.BOOL
SetupDiSetClassPropertyW.argtypes = [
ctypes.c_void_p, # ClassGuid : GUID*
ctypes.c_void_p, # PropertyKey : DEVPROPKEY*
wintypes.DWORD, # PropertyType : DEVPROPTYPE
ctypes.POINTER(ctypes.c_ubyte), # PropertyBuffer : BYTE* optional
wintypes.DWORD, # PropertyBufferSize : DWORD
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')
SetupDiSetClassPropertyW = Fiddle::Function.new(
lib['SetupDiSetClassPropertyW'],
[
Fiddle::TYPE_VOIDP, # ClassGuid : GUID*
Fiddle::TYPE_VOIDP, # PropertyKey : DEVPROPKEY*
-Fiddle::TYPE_INT, # PropertyType : DEVPROPTYPE
Fiddle::TYPE_VOIDP, # PropertyBuffer : BYTE* optional
-Fiddle::TYPE_INT, # PropertyBufferSize : DWORD
-Fiddle::TYPE_INT, # Flags : DWORD
],
Fiddle::TYPE_INT)#[link(name = "setupapi")]
extern "system" {
fn SetupDiSetClassPropertyW(
ClassGuid: *const GUID, // GUID*
PropertyKey: *const DEVPROPKEY, // DEVPROPKEY*
PropertyType: u32, // DEVPROPTYPE
PropertyBuffer: *const u8, // BYTE* optional
PropertyBufferSize: u32, // DWORD
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 SetupDiSetClassPropertyW(ref Guid ClassGuid, IntPtr PropertyKey, uint PropertyType, IntPtr PropertyBuffer, uint PropertyBufferSize, uint Flags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupDiSetClassPropertyW' -Namespace Win32 -PassThru
# $api::SetupDiSetClassPropertyW(ClassGuid, PropertyKey, PropertyType, PropertyBuffer, PropertyBufferSize, Flags)#uselib "SETUPAPI.dll"
#func global SetupDiSetClassPropertyW "SetupDiSetClassPropertyW" sptr, sptr, sptr, sptr, sptr, sptr
; SetupDiSetClassPropertyW varptr(ClassGuid), varptr(PropertyKey), PropertyType, varptr(PropertyBuffer), PropertyBufferSize, Flags ; 戻り値は stat
; ClassGuid : GUID* -> "sptr"
; PropertyKey : DEVPROPKEY* -> "sptr"
; PropertyType : DEVPROPTYPE -> "sptr"
; PropertyBuffer : BYTE* optional -> "sptr"
; PropertyBufferSize : DWORD -> "sptr"
; Flags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SETUPAPI.dll" #cfunc global SetupDiSetClassPropertyW "SetupDiSetClassPropertyW" var, var, int, var, int, int ; res = SetupDiSetClassPropertyW(ClassGuid, PropertyKey, PropertyType, PropertyBuffer, PropertyBufferSize, Flags) ; ClassGuid : GUID* -> "var" ; PropertyKey : DEVPROPKEY* -> "var" ; PropertyType : DEVPROPTYPE -> "int" ; PropertyBuffer : BYTE* optional -> "var" ; PropertyBufferSize : DWORD -> "int" ; Flags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SETUPAPI.dll" #cfunc global SetupDiSetClassPropertyW "SetupDiSetClassPropertyW" sptr, sptr, int, sptr, int, int ; res = SetupDiSetClassPropertyW(varptr(ClassGuid), varptr(PropertyKey), PropertyType, varptr(PropertyBuffer), PropertyBufferSize, Flags) ; ClassGuid : GUID* -> "sptr" ; PropertyKey : DEVPROPKEY* -> "sptr" ; PropertyType : DEVPROPTYPE -> "int" ; PropertyBuffer : BYTE* optional -> "sptr" ; PropertyBufferSize : DWORD -> "int" ; Flags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL SetupDiSetClassPropertyW(GUID* ClassGuid, DEVPROPKEY* PropertyKey, DEVPROPTYPE PropertyType, BYTE* PropertyBuffer, DWORD PropertyBufferSize, DWORD Flags) #uselib "SETUPAPI.dll" #cfunc global SetupDiSetClassPropertyW "SetupDiSetClassPropertyW" var, var, int, var, int, int ; res = SetupDiSetClassPropertyW(ClassGuid, PropertyKey, PropertyType, PropertyBuffer, PropertyBufferSize, Flags) ; ClassGuid : GUID* -> "var" ; PropertyKey : DEVPROPKEY* -> "var" ; PropertyType : DEVPROPTYPE -> "int" ; PropertyBuffer : BYTE* optional -> "var" ; PropertyBufferSize : DWORD -> "int" ; Flags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL SetupDiSetClassPropertyW(GUID* ClassGuid, DEVPROPKEY* PropertyKey, DEVPROPTYPE PropertyType, BYTE* PropertyBuffer, DWORD PropertyBufferSize, DWORD Flags) #uselib "SETUPAPI.dll" #cfunc global SetupDiSetClassPropertyW "SetupDiSetClassPropertyW" intptr, intptr, int, intptr, int, int ; res = SetupDiSetClassPropertyW(varptr(ClassGuid), varptr(PropertyKey), PropertyType, varptr(PropertyBuffer), PropertyBufferSize, Flags) ; ClassGuid : GUID* -> "intptr" ; PropertyKey : DEVPROPKEY* -> "intptr" ; PropertyType : DEVPROPTYPE -> "int" ; PropertyBuffer : BYTE* optional -> "intptr" ; PropertyBufferSize : DWORD -> "int" ; Flags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
procSetupDiSetClassPropertyW = setupapi.NewProc("SetupDiSetClassPropertyW")
)
// ClassGuid (GUID*), PropertyKey (DEVPROPKEY*), PropertyType (DEVPROPTYPE), PropertyBuffer (BYTE* optional), PropertyBufferSize (DWORD), Flags (DWORD)
r1, _, err := procSetupDiSetClassPropertyW.Call(
uintptr(ClassGuid),
uintptr(PropertyKey),
uintptr(PropertyType),
uintptr(PropertyBuffer),
uintptr(PropertyBufferSize),
uintptr(Flags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetupDiSetClassPropertyW(
ClassGuid: PGUID; // GUID*
PropertyKey: Pointer; // DEVPROPKEY*
PropertyType: DWORD; // DEVPROPTYPE
PropertyBuffer: Pointer; // BYTE* optional
PropertyBufferSize: DWORD; // DWORD
Flags: DWORD // DWORD
): BOOL; stdcall;
external 'SETUPAPI.dll' name 'SetupDiSetClassPropertyW';result := DllCall("SETUPAPI\SetupDiSetClassPropertyW"
, "Ptr", ClassGuid ; GUID*
, "Ptr", PropertyKey ; DEVPROPKEY*
, "UInt", PropertyType ; DEVPROPTYPE
, "Ptr", PropertyBuffer ; BYTE* optional
, "UInt", PropertyBufferSize ; DWORD
, "UInt", Flags ; DWORD
, "Int") ; return: BOOL●SetupDiSetClassPropertyW(ClassGuid, PropertyKey, PropertyType, PropertyBuffer, PropertyBufferSize, Flags) = DLL("SETUPAPI.dll", "bool SetupDiSetClassPropertyW(void*, void*, dword, void*, dword, dword)")
# 呼び出し: SetupDiSetClassPropertyW(ClassGuid, PropertyKey, PropertyType, PropertyBuffer, PropertyBufferSize, Flags)
# ClassGuid : GUID* -> "void*"
# PropertyKey : DEVPROPKEY* -> "void*"
# PropertyType : DEVPROPTYPE -> "dword"
# PropertyBuffer : BYTE* optional -> "void*"
# PropertyBufferSize : DWORD -> "dword"
# Flags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。