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

SetupAddInstallSectionToDiskSpaceListA

関数
INFのインストールセクションをディスク容量リストに追加する。
DLLSETUPAPI.dll文字セットANSI (-A)呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

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

BOOL SetupAddInstallSectionToDiskSpaceListA(
    void* DiskSpace,
    void* InfHandle,
    void* LayoutInfHandle,   // optional
    LPCSTR SectionName,
    void* Reserved1,   // optional
    DWORD Reserved2   // optional
);

パラメーター

名前方向
DiskSpacevoid*in
InfHandlevoid*in
LayoutInfHandlevoid*inoptional
SectionNameLPCSTRin
Reserved1void*optional
Reserved2DWORDoptional

戻り値の型: BOOL

各言語での呼び出し定義

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

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

SetupAddInstallSectionToDiskSpaceListA = ctypes.windll.setupapi.SetupAddInstallSectionToDiskSpaceListA
SetupAddInstallSectionToDiskSpaceListA.restype = wintypes.BOOL
SetupAddInstallSectionToDiskSpaceListA.argtypes = [
    ctypes.POINTER(None),  # DiskSpace : void*
    ctypes.POINTER(None),  # InfHandle : void*
    ctypes.POINTER(None),  # LayoutInfHandle : void* optional
    wintypes.LPCSTR,  # SectionName : LPCSTR
    ctypes.POINTER(None),  # Reserved1 : void* optional
    wintypes.DWORD,  # Reserved2 : DWORD optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SETUPAPI.dll')
SetupAddInstallSectionToDiskSpaceListA = Fiddle::Function.new(
  lib['SetupAddInstallSectionToDiskSpaceListA'],
  [
    Fiddle::TYPE_VOIDP,  # DiskSpace : void*
    Fiddle::TYPE_VOIDP,  # InfHandle : void*
    Fiddle::TYPE_VOIDP,  # LayoutInfHandle : void* optional
    Fiddle::TYPE_VOIDP,  # SectionName : LPCSTR
    Fiddle::TYPE_VOIDP,  # Reserved1 : void* optional
    -Fiddle::TYPE_INT,  # Reserved2 : DWORD optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "setupapi")]
extern "system" {
    fn SetupAddInstallSectionToDiskSpaceListA(
        DiskSpace: *mut (),  // void*
        InfHandle: *mut (),  // void*
        LayoutInfHandle: *mut (),  // void* optional
        SectionName: *const u8,  // LPCSTR
        Reserved1: *mut (),  // void* optional
        Reserved2: u32  // DWORD 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 SetupAddInstallSectionToDiskSpaceListA(IntPtr DiskSpace, IntPtr InfHandle, IntPtr LayoutInfHandle, [MarshalAs(UnmanagedType.LPStr)] string SectionName, IntPtr Reserved1, uint Reserved2);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupAddInstallSectionToDiskSpaceListA' -Namespace Win32 -PassThru
# $api::SetupAddInstallSectionToDiskSpaceListA(DiskSpace, InfHandle, LayoutInfHandle, SectionName, Reserved1, Reserved2)
#uselib "SETUPAPI.dll"
#func global SetupAddInstallSectionToDiskSpaceListA "SetupAddInstallSectionToDiskSpaceListA" sptr, sptr, sptr, sptr, sptr, sptr
; SetupAddInstallSectionToDiskSpaceListA DiskSpace, InfHandle, LayoutInfHandle, SectionName, Reserved1, Reserved2   ; 戻り値は stat
; DiskSpace : void* -> "sptr"
; InfHandle : void* -> "sptr"
; LayoutInfHandle : void* optional -> "sptr"
; SectionName : LPCSTR -> "sptr"
; Reserved1 : void* optional -> "sptr"
; Reserved2 : DWORD optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SETUPAPI.dll"
#cfunc global SetupAddInstallSectionToDiskSpaceListA "SetupAddInstallSectionToDiskSpaceListA" sptr, sptr, sptr, str, sptr, int
; res = SetupAddInstallSectionToDiskSpaceListA(DiskSpace, InfHandle, LayoutInfHandle, SectionName, Reserved1, Reserved2)
; DiskSpace : void* -> "sptr"
; InfHandle : void* -> "sptr"
; LayoutInfHandle : void* optional -> "sptr"
; SectionName : LPCSTR -> "str"
; Reserved1 : void* optional -> "sptr"
; Reserved2 : DWORD optional -> "int"
; BOOL SetupAddInstallSectionToDiskSpaceListA(void* DiskSpace, void* InfHandle, void* LayoutInfHandle, LPCSTR SectionName, void* Reserved1, DWORD Reserved2)
#uselib "SETUPAPI.dll"
#cfunc global SetupAddInstallSectionToDiskSpaceListA "SetupAddInstallSectionToDiskSpaceListA" intptr, intptr, intptr, str, intptr, int
; res = SetupAddInstallSectionToDiskSpaceListA(DiskSpace, InfHandle, LayoutInfHandle, SectionName, Reserved1, Reserved2)
; DiskSpace : void* -> "intptr"
; InfHandle : void* -> "intptr"
; LayoutInfHandle : void* optional -> "intptr"
; SectionName : LPCSTR -> "str"
; Reserved1 : void* optional -> "intptr"
; Reserved2 : DWORD optional -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
	procSetupAddInstallSectionToDiskSpaceListA = setupapi.NewProc("SetupAddInstallSectionToDiskSpaceListA")
)

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