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