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