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

SetupRemoveInstallSectionFromDiskSpaceListW

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

シグネチャ

// SETUPAPI.dll  (Unicode / -W)
#include <windows.h>

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

パラメーター

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

戻り値の型: BOOL

各言語での呼び出し定義

// SETUPAPI.dll  (Unicode / -W)
#include <windows.h>

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

SetupRemoveInstallSectionFromDiskSpaceListW = ctypes.windll.setupapi.SetupRemoveInstallSectionFromDiskSpaceListW
SetupRemoveInstallSectionFromDiskSpaceListW.restype = wintypes.BOOL
SetupRemoveInstallSectionFromDiskSpaceListW.argtypes = [
    ctypes.POINTER(None),  # DiskSpace : void*
    ctypes.POINTER(None),  # InfHandle : void*
    ctypes.POINTER(None),  # LayoutInfHandle : void* optional
    wintypes.LPCWSTR,  # SectionName : LPCWSTR
    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')
SetupRemoveInstallSectionFromDiskSpaceListW = Fiddle::Function.new(
  lib['SetupRemoveInstallSectionFromDiskSpaceListW'],
  [
    Fiddle::TYPE_VOIDP,  # DiskSpace : void*
    Fiddle::TYPE_VOIDP,  # InfHandle : void*
    Fiddle::TYPE_VOIDP,  # LayoutInfHandle : void* optional
    Fiddle::TYPE_VOIDP,  # SectionName : LPCWSTR
    Fiddle::TYPE_VOIDP,  # Reserved1 : void* optional
    -Fiddle::TYPE_INT,  # Reserved2 : DWORD optional
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "setupapi")]
extern "system" {
    fn SetupRemoveInstallSectionFromDiskSpaceListW(
        DiskSpace: *mut (),  // void*
        InfHandle: *mut (),  // void*
        LayoutInfHandle: *mut (),  // void* optional
        SectionName: *const u16,  // LPCWSTR
        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.Unicode, SetLastError = true)]
public static extern bool SetupRemoveInstallSectionFromDiskSpaceListW(IntPtr DiskSpace, IntPtr InfHandle, IntPtr LayoutInfHandle, [MarshalAs(UnmanagedType.LPWStr)] string SectionName, IntPtr Reserved1, uint Reserved2);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupRemoveInstallSectionFromDiskSpaceListW' -Namespace Win32 -PassThru
# $api::SetupRemoveInstallSectionFromDiskSpaceListW(DiskSpace, InfHandle, LayoutInfHandle, SectionName, Reserved1, Reserved2)
#uselib "SETUPAPI.dll"
#func global SetupRemoveInstallSectionFromDiskSpaceListW "SetupRemoveInstallSectionFromDiskSpaceListW" wptr, wptr, wptr, wptr, wptr, wptr
; SetupRemoveInstallSectionFromDiskSpaceListW DiskSpace, InfHandle, LayoutInfHandle, SectionName, Reserved1, Reserved2   ; 戻り値は stat
; DiskSpace : void* -> "wptr"
; InfHandle : void* -> "wptr"
; LayoutInfHandle : void* optional -> "wptr"
; SectionName : LPCWSTR -> "wptr"
; Reserved1 : void* optional -> "wptr"
; Reserved2 : DWORD optional -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SETUPAPI.dll"
#cfunc global SetupRemoveInstallSectionFromDiskSpaceListW "SetupRemoveInstallSectionFromDiskSpaceListW" sptr, sptr, sptr, wstr, sptr, int
; res = SetupRemoveInstallSectionFromDiskSpaceListW(DiskSpace, InfHandle, LayoutInfHandle, SectionName, Reserved1, Reserved2)
; DiskSpace : void* -> "sptr"
; InfHandle : void* -> "sptr"
; LayoutInfHandle : void* optional -> "sptr"
; SectionName : LPCWSTR -> "wstr"
; Reserved1 : void* optional -> "sptr"
; Reserved2 : DWORD optional -> "int"
; BOOL SetupRemoveInstallSectionFromDiskSpaceListW(void* DiskSpace, void* InfHandle, void* LayoutInfHandle, LPCWSTR SectionName, void* Reserved1, DWORD Reserved2)
#uselib "SETUPAPI.dll"
#cfunc global SetupRemoveInstallSectionFromDiskSpaceListW "SetupRemoveInstallSectionFromDiskSpaceListW" intptr, intptr, intptr, wstr, intptr, int
; res = SetupRemoveInstallSectionFromDiskSpaceListW(DiskSpace, InfHandle, LayoutInfHandle, SectionName, Reserved1, Reserved2)
; DiskSpace : void* -> "intptr"
; InfHandle : void* -> "intptr"
; LayoutInfHandle : void* optional -> "intptr"
; SectionName : LPCWSTR -> "wstr"
; Reserved1 : void* optional -> "intptr"
; Reserved2 : DWORD optional -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
	procSetupRemoveInstallSectionFromDiskSpaceListW = setupapi.NewProc("SetupRemoveInstallSectionFromDiskSpaceListW")
)

// DiskSpace (void*), InfHandle (void*), LayoutInfHandle (void* optional), SectionName (LPCWSTR), Reserved1 (void* optional), Reserved2 (DWORD optional)
r1, _, err := procSetupRemoveInstallSectionFromDiskSpaceListW.Call(
	uintptr(DiskSpace),
	uintptr(InfHandle),
	uintptr(LayoutInfHandle),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(SectionName))),
	uintptr(Reserved1),
	uintptr(Reserved2),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function SetupRemoveInstallSectionFromDiskSpaceListW(
  DiskSpace: Pointer;   // void*
  InfHandle: Pointer;   // void*
  LayoutInfHandle: Pointer;   // void* optional
  SectionName: PWideChar;   // LPCWSTR
  Reserved1: Pointer;   // void* optional
  Reserved2: DWORD   // DWORD optional
): BOOL; stdcall;
  external 'SETUPAPI.dll' name 'SetupRemoveInstallSectionFromDiskSpaceListW';
result := DllCall("SETUPAPI\SetupRemoveInstallSectionFromDiskSpaceListW"
    , "Ptr", DiskSpace   ; void*
    , "Ptr", InfHandle   ; void*
    , "Ptr", LayoutInfHandle   ; void* optional
    , "WStr", SectionName   ; LPCWSTR
    , "Ptr", Reserved1   ; void* optional
    , "UInt", Reserved2   ; DWORD optional
    , "Int")   ; return: BOOL
●SetupRemoveInstallSectionFromDiskSpaceListW(DiskSpace, InfHandle, LayoutInfHandle, SectionName, Reserved1, Reserved2) = DLL("SETUPAPI.dll", "bool SetupRemoveInstallSectionFromDiskSpaceListW(void*, void*, void*, char*, void*, dword)")
# 呼び出し: SetupRemoveInstallSectionFromDiskSpaceListW(DiskSpace, InfHandle, LayoutInfHandle, SectionName, Reserved1, Reserved2)
# DiskSpace : void* -> "void*"
# InfHandle : void* -> "void*"
# LayoutInfHandle : void* optional -> "void*"
# SectionName : LPCWSTR -> "char*"
# Reserved1 : void* optional -> "void*"
# Reserved2 : DWORD optional -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。