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

SetupRemoveInstallSectionFromDiskSpaceListA

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

シグネチャ

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

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

パラメーター

名前方向説明
DiskSpacevoid*in操作を除去するディスク領域リストのハンドル。
InfHandlevoid*inインストールセクションを記述したINFファイルのハンドル。
LayoutInfHandlevoid*inoptionalファイルサイズ情報を持つレイアウトINFのハンドル。NULL可。
SectionNameLPCSTRin除去対象のインストールセクション名(ANSI)。
Reserved1void*optional予約済み。NULLを指定する必要がある。
Reserved2DWORDoptional予約済み。0を指定する必要がある。

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL SetupRemoveInstallSectionFromDiskSpaceListA(
    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 SetupRemoveInstallSectionFromDiskSpaceListA(
    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 SetupRemoveInstallSectionFromDiskSpaceListA(
    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 <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
' DiskSpace : void*
' InfHandle : void*
' LayoutInfHandle : void* optional
' SectionName : LPCSTR
' Reserved1 : void* optional
' Reserved2 : DWORD optional
Declare PtrSafe Function SetupRemoveInstallSectionFromDiskSpaceListA 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

SetupRemoveInstallSectionFromDiskSpaceListA = ctypes.windll.setupapi.SetupRemoveInstallSectionFromDiskSpaceListA
SetupRemoveInstallSectionFromDiskSpaceListA.restype = wintypes.BOOL
SetupRemoveInstallSectionFromDiskSpaceListA.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')
SetupRemoveInstallSectionFromDiskSpaceListA = Fiddle::Function.new(
  lib['SetupRemoveInstallSectionFromDiskSpaceListA'],
  [
    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 SetupRemoveInstallSectionFromDiskSpaceListA(
        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 SetupRemoveInstallSectionFromDiskSpaceListA(IntPtr DiskSpace, IntPtr InfHandle, IntPtr LayoutInfHandle, [MarshalAs(UnmanagedType.LPStr)] string SectionName, IntPtr Reserved1, uint Reserved2);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupRemoveInstallSectionFromDiskSpaceListA' -Namespace Win32 -PassThru
# $api::SetupRemoveInstallSectionFromDiskSpaceListA(DiskSpace, InfHandle, LayoutInfHandle, SectionName, Reserved1, Reserved2)
#uselib "SETUPAPI.dll"
#func global SetupRemoveInstallSectionFromDiskSpaceListA "SetupRemoveInstallSectionFromDiskSpaceListA" sptr, sptr, sptr, sptr, sptr, sptr
; SetupRemoveInstallSectionFromDiskSpaceListA 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 SetupRemoveInstallSectionFromDiskSpaceListA "SetupRemoveInstallSectionFromDiskSpaceListA" sptr, sptr, sptr, str, sptr, int
; res = SetupRemoveInstallSectionFromDiskSpaceListA(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 SetupRemoveInstallSectionFromDiskSpaceListA(void* DiskSpace, void* InfHandle, void* LayoutInfHandle, LPCSTR SectionName, void* Reserved1, DWORD Reserved2)
#uselib "SETUPAPI.dll"
#cfunc global SetupRemoveInstallSectionFromDiskSpaceListA "SetupRemoveInstallSectionFromDiskSpaceListA" intptr, intptr, intptr, str, intptr, int
; res = SetupRemoveInstallSectionFromDiskSpaceListA(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")
	procSetupRemoveInstallSectionFromDiskSpaceListA = setupapi.NewProc("SetupRemoveInstallSectionFromDiskSpaceListA")
)

// DiskSpace (void*), InfHandle (void*), LayoutInfHandle (void* optional), SectionName (LPCSTR), Reserved1 (void* optional), Reserved2 (DWORD optional)
r1, _, err := procSetupRemoveInstallSectionFromDiskSpaceListA.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 SetupRemoveInstallSectionFromDiskSpaceListA(
  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 'SetupRemoveInstallSectionFromDiskSpaceListA';
result := DllCall("SETUPAPI\SetupRemoveInstallSectionFromDiskSpaceListA"
    , "Ptr", DiskSpace   ; void*
    , "Ptr", InfHandle   ; void*
    , "Ptr", LayoutInfHandle   ; void* optional
    , "AStr", SectionName   ; LPCSTR
    , "Ptr", Reserved1   ; void* optional
    , "UInt", Reserved2   ; DWORD optional
    , "Int")   ; return: BOOL
●SetupRemoveInstallSectionFromDiskSpaceListA(DiskSpace, InfHandle, LayoutInfHandle, SectionName, Reserved1, Reserved2) = DLL("SETUPAPI.dll", "bool SetupRemoveInstallSectionFromDiskSpaceListA(void*, void*, void*, char*, void*, dword)")
# 呼び出し: SetupRemoveInstallSectionFromDiskSpaceListA(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)。
const std = @import("std");

extern "setupapi" fn SetupRemoveInstallSectionFromDiskSpaceListA(
    DiskSpace: ?*anyopaque, // void*
    InfHandle: ?*anyopaque, // void*
    LayoutInfHandle: ?*anyopaque, // void* optional
    SectionName: [*c]const u8, // LPCSTR
    Reserved1: ?*anyopaque, // void* optional
    Reserved2: u32 // DWORD optional
) callconv(std.os.windows.WINAPI) i32;
proc SetupRemoveInstallSectionFromDiskSpaceListA(
    DiskSpace: pointer,  # void*
    InfHandle: pointer,  # void*
    LayoutInfHandle: pointer,  # void* optional
    SectionName: cstring,  # LPCSTR
    Reserved1: pointer,  # void* optional
    Reserved2: uint32  # DWORD optional
): int32 {.importc: "SetupRemoveInstallSectionFromDiskSpaceListA", stdcall, dynlib: "SETUPAPI.dll".}
pragma(lib, "setupapi");
extern(Windows)
int SetupRemoveInstallSectionFromDiskSpaceListA(
    void* DiskSpace,   // void*
    void* InfHandle,   // void*
    void* LayoutInfHandle,   // void* optional
    const(char)* SectionName,   // LPCSTR
    void* Reserved1,   // void* optional
    uint Reserved2   // DWORD optional
);
ccall((:SetupRemoveInstallSectionFromDiskSpaceListA, "SETUPAPI.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Cstring, Ptr{Cvoid}, UInt32),
      DiskSpace, InfHandle, LayoutInfHandle, SectionName, Reserved1, Reserved2)
# DiskSpace : void* -> Ptr{Cvoid}
# InfHandle : void* -> Ptr{Cvoid}
# LayoutInfHandle : void* optional -> Ptr{Cvoid}
# SectionName : LPCSTR -> Cstring
# Reserved1 : void* optional -> Ptr{Cvoid}
# Reserved2 : DWORD optional -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t SetupRemoveInstallSectionFromDiskSpaceListA(
    void* DiskSpace,
    void* InfHandle,
    void* LayoutInfHandle,
    const char* SectionName,
    void* Reserved1,
    uint32_t Reserved2);
]]
local setupapi = ffi.load("setupapi")
-- setupapi.SetupRemoveInstallSectionFromDiskSpaceListA(DiskSpace, InfHandle, LayoutInfHandle, SectionName, Reserved1, Reserved2)
-- DiskSpace : void*
-- InfHandle : void*
-- LayoutInfHandle : void* optional
-- SectionName : LPCSTR
-- Reserved1 : void* optional
-- Reserved2 : DWORD optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('SETUPAPI.dll');
const SetupRemoveInstallSectionFromDiskSpaceListA = lib.func('__stdcall', 'SetupRemoveInstallSectionFromDiskSpaceListA', 'int32_t', ['void *', 'void *', 'void *', 'str', 'void *', 'uint32_t']);
// SetupRemoveInstallSectionFromDiskSpaceListA(DiskSpace, InfHandle, LayoutInfHandle, SectionName, Reserved1, Reserved2)
// DiskSpace : void* -> 'void *'
// InfHandle : void* -> 'void *'
// LayoutInfHandle : void* optional -> 'void *'
// SectionName : LPCSTR -> 'str'
// Reserved1 : void* optional -> 'void *'
// Reserved2 : DWORD optional -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("SETUPAPI.dll", {
  SetupRemoveInstallSectionFromDiskSpaceListA: { parameters: ["pointer", "pointer", "pointer", "buffer", "pointer", "u32"], result: "i32" },
});
// lib.symbols.SetupRemoveInstallSectionFromDiskSpaceListA(DiskSpace, InfHandle, LayoutInfHandle, SectionName, Reserved1, Reserved2)
// DiskSpace : void* -> "pointer"
// InfHandle : void* -> "pointer"
// LayoutInfHandle : void* optional -> "pointer"
// SectionName : LPCSTR -> "buffer"
// Reserved1 : void* optional -> "pointer"
// Reserved2 : DWORD optional -> "u32"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t SetupRemoveInstallSectionFromDiskSpaceListA(
    void* DiskSpace,
    void* InfHandle,
    void* LayoutInfHandle,
    const char* SectionName,
    void* Reserved1,
    uint32_t Reserved2);
C, "SETUPAPI.dll");
// $ffi->SetupRemoveInstallSectionFromDiskSpaceListA(DiskSpace, InfHandle, LayoutInfHandle, SectionName, Reserved1, Reserved2);
// DiskSpace : void*
// InfHandle : void*
// LayoutInfHandle : void* optional
// SectionName : LPCSTR
// Reserved1 : void* optional
// Reserved2 : DWORD optional
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Setupapi extends StdCallLibrary {
    Setupapi INSTANCE = Native.load("setupapi", Setupapi.class, W32APIOptions.ASCII_OPTIONS);
    boolean SetupRemoveInstallSectionFromDiskSpaceListA(
        Pointer DiskSpace,   // void*
        Pointer InfHandle,   // void*
        Pointer LayoutInfHandle,   // void* optional
        String SectionName,   // LPCSTR
        Pointer Reserved1,   // void* optional
        int Reserved2   // DWORD optional
    );
}
@[Link("setupapi")]
lib LibSETUPAPI
  fun SetupRemoveInstallSectionFromDiskSpaceListA = SetupRemoveInstallSectionFromDiskSpaceListA(
    DiskSpace : Void*,   # void*
    InfHandle : Void*,   # void*
    LayoutInfHandle : Void*,   # void* optional
    SectionName : UInt8*,   # LPCSTR
    Reserved1 : Void*,   # void* optional
    Reserved2 : UInt32   # DWORD optional
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef SetupRemoveInstallSectionFromDiskSpaceListANative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Utf8>, Pointer<Void>, Uint32);
typedef SetupRemoveInstallSectionFromDiskSpaceListADart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Utf8>, Pointer<Void>, int);
final SetupRemoveInstallSectionFromDiskSpaceListA = DynamicLibrary.open('SETUPAPI.dll')
    .lookupFunction<SetupRemoveInstallSectionFromDiskSpaceListANative, SetupRemoveInstallSectionFromDiskSpaceListADart>('SetupRemoveInstallSectionFromDiskSpaceListA');
// DiskSpace : void* -> Pointer<Void>
// InfHandle : void* -> Pointer<Void>
// LayoutInfHandle : void* optional -> Pointer<Void>
// SectionName : LPCSTR -> Pointer<Utf8>
// Reserved1 : void* optional -> Pointer<Void>
// Reserved2 : DWORD optional -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function SetupRemoveInstallSectionFromDiskSpaceListA(
  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 'SetupRemoveInstallSectionFromDiskSpaceListA';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "SetupRemoveInstallSectionFromDiskSpaceListA"
  c_SetupRemoveInstallSectionFromDiskSpaceListA :: Ptr () -> Ptr () -> Ptr () -> CString -> Ptr () -> Word32 -> IO CInt
-- DiskSpace : void* -> Ptr ()
-- InfHandle : void* -> Ptr ()
-- LayoutInfHandle : void* optional -> Ptr ()
-- SectionName : LPCSTR -> CString
-- Reserved1 : void* optional -> Ptr ()
-- Reserved2 : DWORD optional -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let setupremoveinstallsectionfromdiskspacelista =
  foreign "SetupRemoveInstallSectionFromDiskSpaceListA"
    ((ptr void) @-> (ptr void) @-> (ptr void) @-> string @-> (ptr void) @-> uint32_t @-> returning int32_t)
(* DiskSpace : void* -> (ptr void) *)
(* InfHandle : void* -> (ptr void) *)
(* LayoutInfHandle : void* optional -> (ptr void) *)
(* SectionName : LPCSTR -> string *)
(* Reserved1 : void* optional -> (ptr void) *)
(* Reserved2 : DWORD optional -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library setupapi (t "SETUPAPI.dll"))
(cffi:use-foreign-library setupapi)

(cffi:defcfun ("SetupRemoveInstallSectionFromDiskSpaceListA" setup-remove-install-section-from-disk-space-list-a :convention :stdcall) :int32
  (disk-space :pointer)   ; void*
  (inf-handle :pointer)   ; void*
  (layout-inf-handle :pointer)   ; void* optional
  (section-name :string)   ; LPCSTR
  (reserved1 :pointer)   ; void* optional
  (reserved2 :uint32))   ; DWORD optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SetupRemoveInstallSectionFromDiskSpaceListA = Win32::API::More->new('SETUPAPI',
    'BOOL SetupRemoveInstallSectionFromDiskSpaceListA(LPVOID DiskSpace, LPVOID InfHandle, LPVOID LayoutInfHandle, LPCSTR SectionName, LPVOID Reserved1, DWORD Reserved2)');
# my $ret = $SetupRemoveInstallSectionFromDiskSpaceListA->Call($DiskSpace, $InfHandle, $LayoutInfHandle, $SectionName, $Reserved1, $Reserved2);
# DiskSpace : void* -> LPVOID
# InfHandle : void* -> LPVOID
# LayoutInfHandle : void* optional -> LPVOID
# SectionName : LPCSTR -> LPCSTR
# Reserved1 : void* optional -> LPVOID
# Reserved2 : DWORD optional -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

文字セット違い