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

SetupDiGetActualSectionToInstallExA

関数
指定プラットフォームでインストールする実際のINFセクション名を取得する。
DLLSETUPAPI.dll文字セットANSI (-A)呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

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

BOOL SetupDiGetActualSectionToInstallExA(
    void* InfHandle,
    LPCSTR InfSectionName,
    SP_ALTPLATFORM_INFO_V2* AlternatePlatformInfo,   // optional
    LPSTR InfSectionWithExt,   // optional
    DWORD InfSectionWithExtSize,
    DWORD* RequiredSize,   // optional
    LPSTR* Extension,   // optional
    void* Reserved   // optional
);

パラメーター

名前方向
InfHandlevoid*in
InfSectionNameLPCSTRin
AlternatePlatformInfoSP_ALTPLATFORM_INFO_V2*inoptional
InfSectionWithExtLPSTRoutoptional
InfSectionWithExtSizeDWORDin
RequiredSizeDWORD*outoptional
ExtensionLPSTR*outoptional
Reservedvoid*optional

戻り値の型: BOOL

各言語での呼び出し定義

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

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

SetupDiGetActualSectionToInstallExA = ctypes.windll.setupapi.SetupDiGetActualSectionToInstallExA
SetupDiGetActualSectionToInstallExA.restype = wintypes.BOOL
SetupDiGetActualSectionToInstallExA.argtypes = [
    ctypes.POINTER(None),  # InfHandle : void*
    wintypes.LPCSTR,  # InfSectionName : LPCSTR
    ctypes.c_void_p,  # AlternatePlatformInfo : SP_ALTPLATFORM_INFO_V2* optional
    wintypes.LPSTR,  # InfSectionWithExt : LPSTR optional, out
    wintypes.DWORD,  # InfSectionWithExtSize : DWORD
    ctypes.POINTER(wintypes.DWORD),  # RequiredSize : DWORD* optional, out
    ctypes.c_void_p,  # Extension : LPSTR* optional, out
    ctypes.POINTER(None),  # Reserved : void* optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SETUPAPI.dll')
SetupDiGetActualSectionToInstallExA = Fiddle::Function.new(
  lib['SetupDiGetActualSectionToInstallExA'],
  [
    Fiddle::TYPE_VOIDP,  # InfHandle : void*
    Fiddle::TYPE_VOIDP,  # InfSectionName : LPCSTR
    Fiddle::TYPE_VOIDP,  # AlternatePlatformInfo : SP_ALTPLATFORM_INFO_V2* optional
    Fiddle::TYPE_VOIDP,  # InfSectionWithExt : LPSTR optional, out
    -Fiddle::TYPE_INT,  # InfSectionWithExtSize : DWORD
    Fiddle::TYPE_VOIDP,  # RequiredSize : DWORD* optional, out
    Fiddle::TYPE_VOIDP,  # Extension : LPSTR* optional, out
    Fiddle::TYPE_VOIDP,  # Reserved : void* optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "setupapi")]
extern "system" {
    fn SetupDiGetActualSectionToInstallExA(
        InfHandle: *mut (),  // void*
        InfSectionName: *const u8,  // LPCSTR
        AlternatePlatformInfo: *mut SP_ALTPLATFORM_INFO_V2,  // SP_ALTPLATFORM_INFO_V2* optional
        InfSectionWithExt: *mut u8,  // LPSTR optional, out
        InfSectionWithExtSize: u32,  // DWORD
        RequiredSize: *mut u32,  // DWORD* optional, out
        Extension: *mut *mut u8,  // LPSTR* optional, out
        Reserved: *mut ()  // void* optional
    ) -> 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 SetupDiGetActualSectionToInstallExA(IntPtr InfHandle, [MarshalAs(UnmanagedType.LPStr)] string InfSectionName, IntPtr AlternatePlatformInfo, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder InfSectionWithExt, uint InfSectionWithExtSize, IntPtr RequiredSize, IntPtr Extension, IntPtr Reserved);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupDiGetActualSectionToInstallExA' -Namespace Win32 -PassThru
# $api::SetupDiGetActualSectionToInstallExA(InfHandle, InfSectionName, AlternatePlatformInfo, InfSectionWithExt, InfSectionWithExtSize, RequiredSize, Extension, Reserved)
#uselib "SETUPAPI.dll"
#func global SetupDiGetActualSectionToInstallExA "SetupDiGetActualSectionToInstallExA" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; SetupDiGetActualSectionToInstallExA InfHandle, InfSectionName, varptr(AlternatePlatformInfo), varptr(InfSectionWithExt), InfSectionWithExtSize, varptr(RequiredSize), varptr(Extension), Reserved   ; 戻り値は stat
; InfHandle : void* -> "sptr"
; InfSectionName : LPCSTR -> "sptr"
; AlternatePlatformInfo : SP_ALTPLATFORM_INFO_V2* optional -> "sptr"
; InfSectionWithExt : LPSTR optional, out -> "sptr"
; InfSectionWithExtSize : DWORD -> "sptr"
; RequiredSize : DWORD* optional, out -> "sptr"
; Extension : LPSTR* optional, out -> "sptr"
; Reserved : void* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "SETUPAPI.dll"
#cfunc global SetupDiGetActualSectionToInstallExA "SetupDiGetActualSectionToInstallExA" sptr, str, var, var, int, var, var, sptr
; res = SetupDiGetActualSectionToInstallExA(InfHandle, InfSectionName, AlternatePlatformInfo, InfSectionWithExt, InfSectionWithExtSize, RequiredSize, Extension, Reserved)
; InfHandle : void* -> "sptr"
; InfSectionName : LPCSTR -> "str"
; AlternatePlatformInfo : SP_ALTPLATFORM_INFO_V2* optional -> "var"
; InfSectionWithExt : LPSTR optional, out -> "var"
; InfSectionWithExtSize : DWORD -> "int"
; RequiredSize : DWORD* optional, out -> "var"
; Extension : LPSTR* optional, out -> "var"
; Reserved : void* optional -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL SetupDiGetActualSectionToInstallExA(void* InfHandle, LPCSTR InfSectionName, SP_ALTPLATFORM_INFO_V2* AlternatePlatformInfo, LPSTR InfSectionWithExt, DWORD InfSectionWithExtSize, DWORD* RequiredSize, LPSTR* Extension, void* Reserved)
#uselib "SETUPAPI.dll"
#cfunc global SetupDiGetActualSectionToInstallExA "SetupDiGetActualSectionToInstallExA" intptr, str, var, var, int, var, var, intptr
; res = SetupDiGetActualSectionToInstallExA(InfHandle, InfSectionName, AlternatePlatformInfo, InfSectionWithExt, InfSectionWithExtSize, RequiredSize, Extension, Reserved)
; InfHandle : void* -> "intptr"
; InfSectionName : LPCSTR -> "str"
; AlternatePlatformInfo : SP_ALTPLATFORM_INFO_V2* optional -> "var"
; InfSectionWithExt : LPSTR optional, out -> "var"
; InfSectionWithExtSize : DWORD -> "int"
; RequiredSize : DWORD* optional, out -> "var"
; Extension : LPSTR* optional, out -> "var"
; Reserved : void* optional -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
	procSetupDiGetActualSectionToInstallExA = setupapi.NewProc("SetupDiGetActualSectionToInstallExA")
)

// InfHandle (void*), InfSectionName (LPCSTR), AlternatePlatformInfo (SP_ALTPLATFORM_INFO_V2* optional), InfSectionWithExt (LPSTR optional, out), InfSectionWithExtSize (DWORD), RequiredSize (DWORD* optional, out), Extension (LPSTR* optional, out), Reserved (void* optional)
r1, _, err := procSetupDiGetActualSectionToInstallExA.Call(
	uintptr(InfHandle),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(InfSectionName))),
	uintptr(AlternatePlatformInfo),
	uintptr(InfSectionWithExt),
	uintptr(InfSectionWithExtSize),
	uintptr(RequiredSize),
	uintptr(Extension),
	uintptr(Reserved),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function SetupDiGetActualSectionToInstallExA(
  InfHandle: Pointer;   // void*
  InfSectionName: PAnsiChar;   // LPCSTR
  AlternatePlatformInfo: Pointer;   // SP_ALTPLATFORM_INFO_V2* optional
  InfSectionWithExt: PAnsiChar;   // LPSTR optional, out
  InfSectionWithExtSize: DWORD;   // DWORD
  RequiredSize: Pointer;   // DWORD* optional, out
  Extension: PPAnsiChar;   // LPSTR* optional, out
  Reserved: Pointer   // void* optional
): BOOL; stdcall;
  external 'SETUPAPI.dll' name 'SetupDiGetActualSectionToInstallExA';
result := DllCall("SETUPAPI\SetupDiGetActualSectionToInstallExA"
    , "Ptr", InfHandle   ; void*
    , "AStr", InfSectionName   ; LPCSTR
    , "Ptr", AlternatePlatformInfo   ; SP_ALTPLATFORM_INFO_V2* optional
    , "Ptr", InfSectionWithExt   ; LPSTR optional, out
    , "UInt", InfSectionWithExtSize   ; DWORD
    , "Ptr", RequiredSize   ; DWORD* optional, out
    , "Ptr", Extension   ; LPSTR* optional, out
    , "Ptr", Reserved   ; void* optional
    , "Int")   ; return: BOOL
●SetupDiGetActualSectionToInstallExA(InfHandle, InfSectionName, AlternatePlatformInfo, InfSectionWithExt, InfSectionWithExtSize, RequiredSize, Extension, Reserved) = DLL("SETUPAPI.dll", "bool SetupDiGetActualSectionToInstallExA(void*, char*, void*, char*, dword, void*, void*, void*)")
# 呼び出し: SetupDiGetActualSectionToInstallExA(InfHandle, InfSectionName, AlternatePlatformInfo, InfSectionWithExt, InfSectionWithExtSize, RequiredSize, Extension, Reserved)
# InfHandle : void* -> "void*"
# InfSectionName : LPCSTR -> "char*"
# AlternatePlatformInfo : SP_ALTPLATFORM_INFO_V2* optional -> "void*"
# InfSectionWithExt : LPSTR optional, out -> "char*"
# InfSectionWithExtSize : DWORD -> "dword"
# RequiredSize : DWORD* optional, out -> "void*"
# Extension : LPSTR* optional, out -> "void*"
# Reserved : void* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。