Win32 API 日本語リファレンス
ホームDevices.DeviceAndDriverInstallation › SetupDiDestroyDriverInfoList

SetupDiDestroyDriverInfoList

関数
デバイスのドライバ情報リストを破棄し解放する。
DLLSETUPAPI.dll呼出規約winapiSetLastErrorあり対応OSWindows 2000 以降

シグネチャ

// SETUPAPI.dll
#include <windows.h>

BOOL SetupDiDestroyDriverInfoList(
    HDEVINFO DeviceInfoSet,
    SP_DEVINFO_DATA* DeviceInfoData,   // optional
    SETUP_DI_DRIVER_TYPE DriverType
);

パラメーター

名前方向
DeviceInfoSetHDEVINFOin
DeviceInfoDataSP_DEVINFO_DATA*inoptional
DriverTypeSETUP_DI_DRIVER_TYPEin

戻り値の型: BOOL

各言語での呼び出し定義

// SETUPAPI.dll
#include <windows.h>

BOOL SetupDiDestroyDriverInfoList(
    HDEVINFO DeviceInfoSet,
    SP_DEVINFO_DATA* DeviceInfoData,   // optional
    SETUP_DI_DRIVER_TYPE DriverType
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", SetLastError = true, ExactSpelling = true)]
static extern bool SetupDiDestroyDriverInfoList(
    IntPtr DeviceInfoSet,   // HDEVINFO
    IntPtr DeviceInfoData,   // SP_DEVINFO_DATA* optional
    uint DriverType   // SETUP_DI_DRIVER_TYPE
);
<DllImport("SETUPAPI.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupDiDestroyDriverInfoList(
    DeviceInfoSet As IntPtr,   ' HDEVINFO
    DeviceInfoData As IntPtr,   ' SP_DEVINFO_DATA* optional
    DriverType As UInteger   ' SETUP_DI_DRIVER_TYPE
) As Boolean
End Function
' DeviceInfoSet : HDEVINFO
' DeviceInfoData : SP_DEVINFO_DATA* optional
' DriverType : SETUP_DI_DRIVER_TYPE
Declare PtrSafe Function SetupDiDestroyDriverInfoList Lib "setupapi" ( _
    ByVal DeviceInfoSet As LongPtr, _
    ByVal DeviceInfoData As LongPtr, _
    ByVal DriverType As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SetupDiDestroyDriverInfoList = ctypes.windll.setupapi.SetupDiDestroyDriverInfoList
SetupDiDestroyDriverInfoList.restype = wintypes.BOOL
SetupDiDestroyDriverInfoList.argtypes = [
    ctypes.c_ssize_t,  # DeviceInfoSet : HDEVINFO
    ctypes.c_void_p,  # DeviceInfoData : SP_DEVINFO_DATA* optional
    wintypes.DWORD,  # DriverType : SETUP_DI_DRIVER_TYPE
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SETUPAPI.dll')
SetupDiDestroyDriverInfoList = Fiddle::Function.new(
  lib['SetupDiDestroyDriverInfoList'],
  [
    Fiddle::TYPE_INTPTR_T,  # DeviceInfoSet : HDEVINFO
    Fiddle::TYPE_VOIDP,  # DeviceInfoData : SP_DEVINFO_DATA* optional
    -Fiddle::TYPE_INT,  # DriverType : SETUP_DI_DRIVER_TYPE
  ],
  Fiddle::TYPE_INT)
#[link(name = "setupapi")]
extern "system" {
    fn SetupDiDestroyDriverInfoList(
        DeviceInfoSet: isize,  // HDEVINFO
        DeviceInfoData: *mut SP_DEVINFO_DATA,  // SP_DEVINFO_DATA* optional
        DriverType: u32  // SETUP_DI_DRIVER_TYPE
    ) -> 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 SetupDiDestroyDriverInfoList(IntPtr DeviceInfoSet, IntPtr DeviceInfoData, uint DriverType);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupDiDestroyDriverInfoList' -Namespace Win32 -PassThru
# $api::SetupDiDestroyDriverInfoList(DeviceInfoSet, DeviceInfoData, DriverType)
#uselib "SETUPAPI.dll"
#func global SetupDiDestroyDriverInfoList "SetupDiDestroyDriverInfoList" sptr, sptr, sptr
; SetupDiDestroyDriverInfoList DeviceInfoSet, varptr(DeviceInfoData), DriverType   ; 戻り値は stat
; DeviceInfoSet : HDEVINFO -> "sptr"
; DeviceInfoData : SP_DEVINFO_DATA* optional -> "sptr"
; DriverType : SETUP_DI_DRIVER_TYPE -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "SETUPAPI.dll"
#cfunc global SetupDiDestroyDriverInfoList "SetupDiDestroyDriverInfoList" sptr, var, int
; res = SetupDiDestroyDriverInfoList(DeviceInfoSet, DeviceInfoData, DriverType)
; DeviceInfoSet : HDEVINFO -> "sptr"
; DeviceInfoData : SP_DEVINFO_DATA* optional -> "var"
; DriverType : SETUP_DI_DRIVER_TYPE -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL SetupDiDestroyDriverInfoList(HDEVINFO DeviceInfoSet, SP_DEVINFO_DATA* DeviceInfoData, SETUP_DI_DRIVER_TYPE DriverType)
#uselib "SETUPAPI.dll"
#cfunc global SetupDiDestroyDriverInfoList "SetupDiDestroyDriverInfoList" intptr, var, int
; res = SetupDiDestroyDriverInfoList(DeviceInfoSet, DeviceInfoData, DriverType)
; DeviceInfoSet : HDEVINFO -> "intptr"
; DeviceInfoData : SP_DEVINFO_DATA* optional -> "var"
; DriverType : SETUP_DI_DRIVER_TYPE -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
	procSetupDiDestroyDriverInfoList = setupapi.NewProc("SetupDiDestroyDriverInfoList")
)

// DeviceInfoSet (HDEVINFO), DeviceInfoData (SP_DEVINFO_DATA* optional), DriverType (SETUP_DI_DRIVER_TYPE)
r1, _, err := procSetupDiDestroyDriverInfoList.Call(
	uintptr(DeviceInfoSet),
	uintptr(DeviceInfoData),
	uintptr(DriverType),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function SetupDiDestroyDriverInfoList(
  DeviceInfoSet: NativeInt;   // HDEVINFO
  DeviceInfoData: Pointer;   // SP_DEVINFO_DATA* optional
  DriverType: DWORD   // SETUP_DI_DRIVER_TYPE
): BOOL; stdcall;
  external 'SETUPAPI.dll' name 'SetupDiDestroyDriverInfoList';
result := DllCall("SETUPAPI\SetupDiDestroyDriverInfoList"
    , "Ptr", DeviceInfoSet   ; HDEVINFO
    , "Ptr", DeviceInfoData   ; SP_DEVINFO_DATA* optional
    , "UInt", DriverType   ; SETUP_DI_DRIVER_TYPE
    , "Int")   ; return: BOOL
●SetupDiDestroyDriverInfoList(DeviceInfoSet, DeviceInfoData, DriverType) = DLL("SETUPAPI.dll", "bool SetupDiDestroyDriverInfoList(int, void*, dword)")
# 呼び出し: SetupDiDestroyDriverInfoList(DeviceInfoSet, DeviceInfoData, DriverType)
# DeviceInfoSet : HDEVINFO -> "int"
# DeviceInfoData : SP_DEVINFO_DATA* optional -> "void*"
# DriverType : SETUP_DI_DRIVER_TYPE -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。