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

SetupDiDestroyDeviceInfoList

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

シグネチャ

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

BOOL SetupDiDestroyDeviceInfoList(
    HDEVINFO DeviceInfoSet
);

パラメーター

名前方向
DeviceInfoSetHDEVINFOin

戻り値の型: BOOL

各言語での呼び出し定義

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

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

SetupDiDestroyDeviceInfoList = ctypes.windll.setupapi.SetupDiDestroyDeviceInfoList
SetupDiDestroyDeviceInfoList.restype = wintypes.BOOL
SetupDiDestroyDeviceInfoList.argtypes = [
    ctypes.c_ssize_t,  # DeviceInfoSet : HDEVINFO
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SETUPAPI.dll')
SetupDiDestroyDeviceInfoList = Fiddle::Function.new(
  lib['SetupDiDestroyDeviceInfoList'],
  [
    Fiddle::TYPE_INTPTR_T,  # DeviceInfoSet : HDEVINFO
  ],
  Fiddle::TYPE_INT)
#[link(name = "setupapi")]
extern "system" {
    fn SetupDiDestroyDeviceInfoList(
        DeviceInfoSet: isize  // HDEVINFO
    ) -> 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 SetupDiDestroyDeviceInfoList(IntPtr DeviceInfoSet);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupDiDestroyDeviceInfoList' -Namespace Win32 -PassThru
# $api::SetupDiDestroyDeviceInfoList(DeviceInfoSet)
#uselib "SETUPAPI.dll"
#func global SetupDiDestroyDeviceInfoList "SetupDiDestroyDeviceInfoList" sptr
; SetupDiDestroyDeviceInfoList DeviceInfoSet   ; 戻り値は stat
; DeviceInfoSet : HDEVINFO -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SETUPAPI.dll"
#cfunc global SetupDiDestroyDeviceInfoList "SetupDiDestroyDeviceInfoList" sptr
; res = SetupDiDestroyDeviceInfoList(DeviceInfoSet)
; DeviceInfoSet : HDEVINFO -> "sptr"
; BOOL SetupDiDestroyDeviceInfoList(HDEVINFO DeviceInfoSet)
#uselib "SETUPAPI.dll"
#cfunc global SetupDiDestroyDeviceInfoList "SetupDiDestroyDeviceInfoList" intptr
; res = SetupDiDestroyDeviceInfoList(DeviceInfoSet)
; DeviceInfoSet : HDEVINFO -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
	procSetupDiDestroyDeviceInfoList = setupapi.NewProc("SetupDiDestroyDeviceInfoList")
)

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