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