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