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

SetupAddSectionToDiskSpaceListA

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

シグネチャ

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

BOOL SetupAddSectionToDiskSpaceListA(
    void* DiskSpace,
    void* InfHandle,
    void* ListInfHandle,   // optional
    LPCSTR SectionName,
    SETUP_FILE_OPERATION Operation,
    void* Reserved1,   // optional
    DWORD Reserved2   // optional
);

パラメーター

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

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL SetupAddSectionToDiskSpaceListA(
    void* DiskSpace,
    void* InfHandle,
    void* ListInfHandle,   // optional
    LPCSTR SectionName,
    SETUP_FILE_OPERATION Operation,
    void* Reserved1,   // optional
    DWORD Reserved2   // optional
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool SetupAddSectionToDiskSpaceListA(
    IntPtr DiskSpace,   // void*
    IntPtr InfHandle,   // void*
    IntPtr ListInfHandle,   // void* optional
    [MarshalAs(UnmanagedType.LPStr)] string SectionName,   // LPCSTR
    uint Operation,   // SETUP_FILE_OPERATION
    IntPtr Reserved1,   // void* optional
    uint Reserved2   // DWORD optional
);
<DllImport("SETUPAPI.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupAddSectionToDiskSpaceListA(
    DiskSpace As IntPtr,   ' void*
    InfHandle As IntPtr,   ' void*
    ListInfHandle As IntPtr,   ' void* optional
    <MarshalAs(UnmanagedType.LPStr)> SectionName As String,   ' LPCSTR
    Operation As UInteger,   ' SETUP_FILE_OPERATION
    Reserved1 As IntPtr,   ' void* optional
    Reserved2 As UInteger   ' DWORD optional
) As Boolean
End Function
' DiskSpace : void*
' InfHandle : void*
' ListInfHandle : void* optional
' SectionName : LPCSTR
' Operation : SETUP_FILE_OPERATION
' Reserved1 : void* optional
' Reserved2 : DWORD optional
Declare PtrSafe Function SetupAddSectionToDiskSpaceListA Lib "setupapi" ( _
    ByVal DiskSpace As LongPtr, _
    ByVal InfHandle As LongPtr, _
    ByVal ListInfHandle As LongPtr, _
    ByVal SectionName As String, _
    ByVal Operation As Long, _
    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

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

var (
	setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
	procSetupAddSectionToDiskSpaceListA = setupapi.NewProc("SetupAddSectionToDiskSpaceListA")
)

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