ホーム › Devices.DeviceAndDriverInstallation › SetupDiDestroyDriverInfoList
SetupDiDestroyDriverInfoList
関数デバイスのドライバ情報リストを破棄し解放する。
シグネチャ
// SETUPAPI.dll
#include <windows.h>
BOOL SetupDiDestroyDriverInfoList(
HDEVINFO DeviceInfoSet,
SP_DEVINFO_DATA* DeviceInfoData, // optional
SETUP_DI_DRIVER_TYPE DriverType
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| DeviceInfoSet | HDEVINFO | in | 対象のデバイス情報セットを指すハンドル。破棄するドライバリストの所属先を示す。 |
| DeviceInfoData | SP_DEVINFO_DATA* | inoptional | ドライバリストが関連付くデバイスの構造体。NULL指定でセット全体のリストを破棄する。 |
| DriverType | SETUP_DI_DRIVER_TYPE | in | 破棄するドライバリストの種別。SPDIT_CLASSDRIVERまたはSPDIT_COMPATDRIVERを指定する。 |
戻り値の型: 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 <MarshalAs(UnmanagedType.Bool)> 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 方式にも切替可。#uselib "SETUPAPI.dll" #cfunc global SetupDiDestroyDriverInfoList "SetupDiDestroyDriverInfoList" sptr, sptr, int ; res = SetupDiDestroyDriverInfoList(DeviceInfoSet, varptr(DeviceInfoData), DriverType) ; DeviceInfoSet : HDEVINFO -> "sptr" ; DeviceInfoData : SP_DEVINFO_DATA* optional -> "sptr" ; DriverType : SETUP_DI_DRIVER_TYPE -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; BOOL SetupDiDestroyDriverInfoList(HDEVINFO DeviceInfoSet, SP_DEVINFO_DATA* DeviceInfoData, SETUP_DI_DRIVER_TYPE DriverType) #uselib "SETUPAPI.dll" #cfunc global SetupDiDestroyDriverInfoList "SetupDiDestroyDriverInfoList" intptr, intptr, int ; res = SetupDiDestroyDriverInfoList(DeviceInfoSet, varptr(DeviceInfoData), DriverType) ; DeviceInfoSet : HDEVINFO -> "intptr" ; DeviceInfoData : SP_DEVINFO_DATA* optional -> "intptr" ; DriverType : SETUP_DI_DRIVER_TYPE -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // BOOLfunction 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)。const std = @import("std");
extern "setupapi" fn SetupDiDestroyDriverInfoList(
DeviceInfoSet: isize, // HDEVINFO
DeviceInfoData: [*c]SP_DEVINFO_DATA, // SP_DEVINFO_DATA* optional
DriverType: u32 // SETUP_DI_DRIVER_TYPE
) callconv(std.os.windows.WINAPI) i32;proc SetupDiDestroyDriverInfoList(
DeviceInfoSet: int, # HDEVINFO
DeviceInfoData: ptr SP_DEVINFO_DATA, # SP_DEVINFO_DATA* optional
DriverType: uint32 # SETUP_DI_DRIVER_TYPE
): int32 {.importc: "SetupDiDestroyDriverInfoList", stdcall, dynlib: "SETUPAPI.dll".}pragma(lib, "setupapi");
extern(Windows)
int SetupDiDestroyDriverInfoList(
ptrdiff_t DeviceInfoSet, // HDEVINFO
SP_DEVINFO_DATA* DeviceInfoData, // SP_DEVINFO_DATA* optional
uint DriverType // SETUP_DI_DRIVER_TYPE
);ccall((:SetupDiDestroyDriverInfoList, "SETUPAPI.dll"), stdcall, Int32,
(Int, Ptr{SP_DEVINFO_DATA}, UInt32),
DeviceInfoSet, DeviceInfoData, DriverType)
# DeviceInfoSet : HDEVINFO -> Int
# DeviceInfoData : SP_DEVINFO_DATA* optional -> Ptr{SP_DEVINFO_DATA}
# DriverType : SETUP_DI_DRIVER_TYPE -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t SetupDiDestroyDriverInfoList(
intptr_t DeviceInfoSet,
void* DeviceInfoData,
uint32_t DriverType);
]]
local setupapi = ffi.load("setupapi")
-- setupapi.SetupDiDestroyDriverInfoList(DeviceInfoSet, DeviceInfoData, DriverType)
-- DeviceInfoSet : HDEVINFO
-- DeviceInfoData : SP_DEVINFO_DATA* optional
-- DriverType : SETUP_DI_DRIVER_TYPE
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('SETUPAPI.dll');
const SetupDiDestroyDriverInfoList = lib.func('__stdcall', 'SetupDiDestroyDriverInfoList', 'int32_t', ['intptr_t', 'void *', 'uint32_t']);
// SetupDiDestroyDriverInfoList(DeviceInfoSet, DeviceInfoData, DriverType)
// DeviceInfoSet : HDEVINFO -> 'intptr_t'
// DeviceInfoData : SP_DEVINFO_DATA* optional -> 'void *'
// DriverType : SETUP_DI_DRIVER_TYPE -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("SETUPAPI.dll", {
SetupDiDestroyDriverInfoList: { parameters: ["isize", "pointer", "u32"], result: "i32" },
});
// lib.symbols.SetupDiDestroyDriverInfoList(DeviceInfoSet, DeviceInfoData, DriverType)
// DeviceInfoSet : HDEVINFO -> "isize"
// DeviceInfoData : SP_DEVINFO_DATA* optional -> "pointer"
// DriverType : SETUP_DI_DRIVER_TYPE -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t SetupDiDestroyDriverInfoList(
intptr_t DeviceInfoSet,
void* DeviceInfoData,
uint32_t DriverType);
C, "SETUPAPI.dll");
// $ffi->SetupDiDestroyDriverInfoList(DeviceInfoSet, DeviceInfoData, DriverType);
// DeviceInfoSet : HDEVINFO
// DeviceInfoData : SP_DEVINFO_DATA* optional
// DriverType : SETUP_DI_DRIVER_TYPE
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Setupapi extends StdCallLibrary {
Setupapi INSTANCE = Native.load("setupapi", Setupapi.class);
boolean SetupDiDestroyDriverInfoList(
long DeviceInfoSet, // HDEVINFO
Pointer DeviceInfoData, // SP_DEVINFO_DATA* optional
int DriverType // SETUP_DI_DRIVER_TYPE
);
}@[Link("setupapi")]
lib LibSETUPAPI
fun SetupDiDestroyDriverInfoList = SetupDiDestroyDriverInfoList(
DeviceInfoSet : LibC::SSizeT, # HDEVINFO
DeviceInfoData : SP_DEVINFO_DATA*, # SP_DEVINFO_DATA* optional
DriverType : UInt32 # SETUP_DI_DRIVER_TYPE
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SetupDiDestroyDriverInfoListNative = Int32 Function(IntPtr, Pointer<Void>, Uint32);
typedef SetupDiDestroyDriverInfoListDart = int Function(int, Pointer<Void>, int);
final SetupDiDestroyDriverInfoList = DynamicLibrary.open('SETUPAPI.dll')
.lookupFunction<SetupDiDestroyDriverInfoListNative, SetupDiDestroyDriverInfoListDart>('SetupDiDestroyDriverInfoList');
// DeviceInfoSet : HDEVINFO -> IntPtr
// DeviceInfoData : SP_DEVINFO_DATA* optional -> Pointer<Void>
// DriverType : SETUP_DI_DRIVER_TYPE -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SetupDiDestroyDriverInfoList(
DeviceInfoSet: NativeInt; // HDEVINFO
DeviceInfoData: Pointer; // SP_DEVINFO_DATA* optional
DriverType: DWORD // SETUP_DI_DRIVER_TYPE
): BOOL; stdcall;
external 'SETUPAPI.dll' name 'SetupDiDestroyDriverInfoList';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SetupDiDestroyDriverInfoList"
c_SetupDiDestroyDriverInfoList :: CIntPtr -> Ptr () -> Word32 -> IO CInt
-- DeviceInfoSet : HDEVINFO -> CIntPtr
-- DeviceInfoData : SP_DEVINFO_DATA* optional -> Ptr ()
-- DriverType : SETUP_DI_DRIVER_TYPE -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let setupdidestroydriverinfolist =
foreign "SetupDiDestroyDriverInfoList"
(intptr_t @-> (ptr void) @-> uint32_t @-> returning int32_t)
(* DeviceInfoSet : HDEVINFO -> intptr_t *)
(* DeviceInfoData : SP_DEVINFO_DATA* optional -> (ptr void) *)
(* DriverType : SETUP_DI_DRIVER_TYPE -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library setupapi (t "SETUPAPI.dll"))
(cffi:use-foreign-library setupapi)
(cffi:defcfun ("SetupDiDestroyDriverInfoList" setup-di-destroy-driver-info-list :convention :stdcall) :int32
(device-info-set :int64) ; HDEVINFO
(device-info-data :pointer) ; SP_DEVINFO_DATA* optional
(driver-type :uint32)) ; SETUP_DI_DRIVER_TYPE
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SetupDiDestroyDriverInfoList = Win32::API::More->new('SETUPAPI',
'BOOL SetupDiDestroyDriverInfoList(LPARAM DeviceInfoSet, LPVOID DeviceInfoData, DWORD DriverType)');
# my $ret = $SetupDiDestroyDriverInfoList->Call($DeviceInfoSet, $DeviceInfoData, $DriverType);
# DeviceInfoSet : HDEVINFO -> LPARAM
# DeviceInfoData : SP_DEVINFO_DATA* optional -> LPVOID
# DriverType : SETUP_DI_DRIVER_TYPE -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。