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

SetupEnumInfSectionsA

関数
INFファイル内のセクションを順に列挙する。
DLLSETUPAPI.dll文字セットANSI (-A)呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

// SETUPAPI.dll  (ANSI / -A)
#include <windows.h>

BOOL SetupEnumInfSectionsA(
    void* InfHandle,
    DWORD Index,
    LPSTR Buffer,   // optional
    DWORD Size,
    DWORD* SizeNeeded   // optional
);

パラメーター

名前方向
InfHandlevoid*in
IndexDWORDin
BufferLPSTRoutoptional
SizeDWORDin
SizeNeededDWORD*outoptional

戻り値の型: BOOL

各言語での呼び出し定義

// SETUPAPI.dll  (ANSI / -A)
#include <windows.h>

BOOL SetupEnumInfSectionsA(
    void* InfHandle,
    DWORD Index,
    LPSTR Buffer,   // optional
    DWORD Size,
    DWORD* SizeNeeded   // optional
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool SetupEnumInfSectionsA(
    IntPtr InfHandle,   // void*
    uint Index,   // DWORD
    [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder Buffer,   // LPSTR optional, out
    uint Size,   // DWORD
    IntPtr SizeNeeded   // DWORD* optional, out
);
<DllImport("SETUPAPI.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupEnumInfSectionsA(
    InfHandle As IntPtr,   ' void*
    Index As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPStr)> Buffer As System.Text.StringBuilder,   ' LPSTR optional, out
    Size As UInteger,   ' DWORD
    SizeNeeded As IntPtr   ' DWORD* optional, out
) As Boolean
End Function
' InfHandle : void*
' Index : DWORD
' Buffer : LPSTR optional, out
' Size : DWORD
' SizeNeeded : DWORD* optional, out
Declare PtrSafe Function SetupEnumInfSectionsA Lib "setupapi" ( _
    ByVal InfHandle As LongPtr, _
    ByVal Index As Long, _
    ByVal Buffer As String, _
    ByVal Size As Long, _
    ByVal SizeNeeded As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SetupEnumInfSectionsA = ctypes.windll.setupapi.SetupEnumInfSectionsA
SetupEnumInfSectionsA.restype = wintypes.BOOL
SetupEnumInfSectionsA.argtypes = [
    ctypes.POINTER(None),  # InfHandle : void*
    wintypes.DWORD,  # Index : DWORD
    wintypes.LPSTR,  # Buffer : LPSTR 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')
SetupEnumInfSectionsA = Fiddle::Function.new(
  lib['SetupEnumInfSectionsA'],
  [
    Fiddle::TYPE_VOIDP,  # InfHandle : void*
    -Fiddle::TYPE_INT,  # Index : DWORD
    Fiddle::TYPE_VOIDP,  # Buffer : LPSTR optional, out
    -Fiddle::TYPE_INT,  # Size : DWORD
    Fiddle::TYPE_VOIDP,  # SizeNeeded : DWORD* optional, out
  ],
  Fiddle::TYPE_INT)
#[link(name = "setupapi")]
extern "system" {
    fn SetupEnumInfSectionsA(
        InfHandle: *mut (),  // void*
        Index: u32,  // DWORD
        Buffer: *mut u8,  // LPSTR 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.Ansi, SetLastError = true)]
public static extern bool SetupEnumInfSectionsA(IntPtr InfHandle, uint Index, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder Buffer, uint Size, IntPtr SizeNeeded);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupEnumInfSectionsA' -Namespace Win32 -PassThru
# $api::SetupEnumInfSectionsA(InfHandle, Index, Buffer, Size, SizeNeeded)
#uselib "SETUPAPI.dll"
#func global SetupEnumInfSectionsA "SetupEnumInfSectionsA" sptr, sptr, sptr, sptr, sptr
; SetupEnumInfSectionsA InfHandle, Index, varptr(Buffer), Size, varptr(SizeNeeded)   ; 戻り値は stat
; InfHandle : void* -> "sptr"
; Index : DWORD -> "sptr"
; Buffer : LPSTR optional, out -> "sptr"
; Size : DWORD -> "sptr"
; SizeNeeded : DWORD* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "SETUPAPI.dll"
#cfunc global SetupEnumInfSectionsA "SetupEnumInfSectionsA" sptr, int, var, int, var
; res = SetupEnumInfSectionsA(InfHandle, Index, Buffer, Size, SizeNeeded)
; InfHandle : void* -> "sptr"
; Index : DWORD -> "int"
; Buffer : LPSTR optional, out -> "var"
; Size : DWORD -> "int"
; SizeNeeded : DWORD* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL SetupEnumInfSectionsA(void* InfHandle, DWORD Index, LPSTR Buffer, DWORD Size, DWORD* SizeNeeded)
#uselib "SETUPAPI.dll"
#cfunc global SetupEnumInfSectionsA "SetupEnumInfSectionsA" intptr, int, var, int, var
; res = SetupEnumInfSectionsA(InfHandle, Index, Buffer, Size, SizeNeeded)
; InfHandle : void* -> "intptr"
; Index : DWORD -> "int"
; Buffer : LPSTR optional, out -> "var"
; Size : DWORD -> "int"
; SizeNeeded : DWORD* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
	procSetupEnumInfSectionsA = setupapi.NewProc("SetupEnumInfSectionsA")
)

// InfHandle (void*), Index (DWORD), Buffer (LPSTR optional, out), Size (DWORD), SizeNeeded (DWORD* optional, out)
r1, _, err := procSetupEnumInfSectionsA.Call(
	uintptr(InfHandle),
	uintptr(Index),
	uintptr(Buffer),
	uintptr(Size),
	uintptr(SizeNeeded),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function SetupEnumInfSectionsA(
  InfHandle: Pointer;   // void*
  Index: DWORD;   // DWORD
  Buffer: PAnsiChar;   // LPSTR optional, out
  Size: DWORD;   // DWORD
  SizeNeeded: Pointer   // DWORD* optional, out
): BOOL; stdcall;
  external 'SETUPAPI.dll' name 'SetupEnumInfSectionsA';
result := DllCall("SETUPAPI\SetupEnumInfSectionsA"
    , "Ptr", InfHandle   ; void*
    , "UInt", Index   ; DWORD
    , "Ptr", Buffer   ; LPSTR optional, out
    , "UInt", Size   ; DWORD
    , "Ptr", SizeNeeded   ; DWORD* optional, out
    , "Int")   ; return: BOOL
●SetupEnumInfSectionsA(InfHandle, Index, Buffer, Size, SizeNeeded) = DLL("SETUPAPI.dll", "bool SetupEnumInfSectionsA(void*, dword, char*, dword, void*)")
# 呼び出し: SetupEnumInfSectionsA(InfHandle, Index, Buffer, Size, SizeNeeded)
# InfHandle : void* -> "void*"
# Index : DWORD -> "dword"
# Buffer : LPSTR optional, out -> "char*"
# Size : DWORD -> "dword"
# SizeNeeded : DWORD* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。