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

SetupRemoveSectionFromDiskSpaceListA

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

シグネチャ

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

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

パラメーター

名前方向説明
DiskSpacevoid*inディスク領域リストへのハンドル。
InfHandlevoid*inSourceDisksFiles セクションを含む、開かれた INF ファイルへのハンドル。ListInfHandle を指定しない場合、この INF ファイルには SectionName で指定されたセクションも含まれている必要があります。
ListInfHandlevoid*inoptionalディスク領域リストから削除するセクションを含む、開かれた INF ファイルへの省略可能なハンドル。指定しない場合は、InfHandleSectionName で指定されたセクションが含まれている必要があります。
SectionNameLPCSTRinディスク領域リストから削除する Copy Files セクションまたは Delete Files セクションの名前を指定する、null で終わる文字列へのポインター。
OperationSETUP_FILE_OPERATIONin

リストから削除するファイル操作。このパラメーターには、次の値のいずれかを指定できます。

意味
FILEOP_DELETE
ファイルの削除操作。
FILEOP_COPY
ファイルのコピー操作。
Reserved1void*optional0 を指定する必要があります。
Reserved2DWORDoptional0 を指定する必要があります。

戻り値の型: BOOL

公式ドキュメント

SetupRemoveSectionFromDiskSpaceList 関数は、INF ファイルの Copy Files セクションに記載されたファイルの削除操作またはコピー操作を、ディスク領域リストから削除します。(ANSI)

戻り値

関数が成功した場合、戻り値は 0 以外の値です。

関数が失敗した場合、戻り値は 0 です。拡張エラー情報を取得するには、 GetLastError を呼び出します。

解説(Remarks)

SetupRemoveSectionFromDiskSpaceList 関数によって削除されるファイル操作は、通常、 SetupAddSectionToDiskSpaceList 関数を使用してリストに追加されたものですが、これは必須ではありません。 SetupRemoveSectionFromDiskSpaceList 関数は、INF セクション内のファイルのうち、ディスク領域リストに記載されていないものは無視します。

この関数には Windows の INF ファイルが必要です。一部の古い形式の INF ファイルはサポートされていない場合があります。

メモ

setupapi.h ヘッダーは、SetupRemoveSectionFromDiskSpaceList を、UNICODE プリプロセッサ定数の定義に基づいてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして定義しています。エンコーディング中立のエイリアスと、エンコーディング中立ではないコードを混在させて使用すると、不一致が生じ、コンパイルエラーまたは実行時エラーの原因となる可能性があります。詳細については、関数プロトタイプの規則を参照してください。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

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

BOOL SetupRemoveSectionFromDiskSpaceListA(
    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 SetupRemoveSectionFromDiskSpaceListA(
    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 SetupRemoveSectionFromDiskSpaceListA(
    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 <MarshalAs(UnmanagedType.Bool)> 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 SetupRemoveSectionFromDiskSpaceListA 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

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

// DiskSpace (void*), InfHandle (void*), ListInfHandle (void* optional), SectionName (LPCSTR), Operation (SETUP_FILE_OPERATION), Reserved1 (void* optional), Reserved2 (DWORD optional)
r1, _, err := procSetupRemoveSectionFromDiskSpaceListA.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 SetupRemoveSectionFromDiskSpaceListA(
  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 'SetupRemoveSectionFromDiskSpaceListA';
result := DllCall("SETUPAPI\SetupRemoveSectionFromDiskSpaceListA"
    , "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
●SetupRemoveSectionFromDiskSpaceListA(DiskSpace, InfHandle, ListInfHandle, SectionName, Operation, Reserved1, Reserved2) = DLL("SETUPAPI.dll", "bool SetupRemoveSectionFromDiskSpaceListA(void*, void*, void*, char*, dword, void*, dword)")
# 呼び出し: SetupRemoveSectionFromDiskSpaceListA(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)。
const std = @import("std");

extern "setupapi" fn SetupRemoveSectionFromDiskSpaceListA(
    DiskSpace: ?*anyopaque, // void*
    InfHandle: ?*anyopaque, // void*
    ListInfHandle: ?*anyopaque, // void* optional
    SectionName: [*c]const u8, // LPCSTR
    Operation: u32, // SETUP_FILE_OPERATION
    Reserved1: ?*anyopaque, // void* optional
    Reserved2: u32 // DWORD optional
) callconv(std.os.windows.WINAPI) i32;
proc SetupRemoveSectionFromDiskSpaceListA(
    DiskSpace: pointer,  # void*
    InfHandle: pointer,  # void*
    ListInfHandle: pointer,  # void* optional
    SectionName: cstring,  # LPCSTR
    Operation: uint32,  # SETUP_FILE_OPERATION
    Reserved1: pointer,  # void* optional
    Reserved2: uint32  # DWORD optional
): int32 {.importc: "SetupRemoveSectionFromDiskSpaceListA", stdcall, dynlib: "SETUPAPI.dll".}
pragma(lib, "setupapi");
extern(Windows)
int SetupRemoveSectionFromDiskSpaceListA(
    void* DiskSpace,   // void*
    void* InfHandle,   // void*
    void* ListInfHandle,   // void* optional
    const(char)* SectionName,   // LPCSTR
    uint Operation,   // SETUP_FILE_OPERATION
    void* Reserved1,   // void* optional
    uint Reserved2   // DWORD optional
);
ccall((:SetupRemoveSectionFromDiskSpaceListA, "SETUPAPI.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Cstring, UInt32, Ptr{Cvoid}, UInt32),
      DiskSpace, InfHandle, ListInfHandle, SectionName, Operation, Reserved1, Reserved2)
# DiskSpace : void* -> Ptr{Cvoid}
# InfHandle : void* -> Ptr{Cvoid}
# ListInfHandle : void* optional -> Ptr{Cvoid}
# SectionName : LPCSTR -> Cstring
# Operation : SETUP_FILE_OPERATION -> UInt32
# Reserved1 : void* optional -> Ptr{Cvoid}
# Reserved2 : DWORD optional -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t SetupRemoveSectionFromDiskSpaceListA(
    void* DiskSpace,
    void* InfHandle,
    void* ListInfHandle,
    const char* SectionName,
    uint32_t Operation,
    void* Reserved1,
    uint32_t Reserved2);
]]
local setupapi = ffi.load("setupapi")
-- setupapi.SetupRemoveSectionFromDiskSpaceListA(DiskSpace, InfHandle, ListInfHandle, SectionName, Operation, Reserved1, Reserved2)
-- DiskSpace : void*
-- InfHandle : void*
-- ListInfHandle : void* optional
-- SectionName : LPCSTR
-- Operation : SETUP_FILE_OPERATION
-- Reserved1 : void* optional
-- Reserved2 : DWORD optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('SETUPAPI.dll');
const SetupRemoveSectionFromDiskSpaceListA = lib.func('__stdcall', 'SetupRemoveSectionFromDiskSpaceListA', 'int32_t', ['void *', 'void *', 'void *', 'str', 'uint32_t', 'void *', 'uint32_t']);
// SetupRemoveSectionFromDiskSpaceListA(DiskSpace, InfHandle, ListInfHandle, SectionName, Operation, Reserved1, Reserved2)
// DiskSpace : void* -> 'void *'
// InfHandle : void* -> 'void *'
// ListInfHandle : void* optional -> 'void *'
// SectionName : LPCSTR -> 'str'
// Operation : SETUP_FILE_OPERATION -> 'uint32_t'
// Reserved1 : void* optional -> 'void *'
// Reserved2 : DWORD optional -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("SETUPAPI.dll", {
  SetupRemoveSectionFromDiskSpaceListA: { parameters: ["pointer", "pointer", "pointer", "buffer", "u32", "pointer", "u32"], result: "i32" },
});
// lib.symbols.SetupRemoveSectionFromDiskSpaceListA(DiskSpace, InfHandle, ListInfHandle, SectionName, Operation, Reserved1, Reserved2)
// DiskSpace : void* -> "pointer"
// InfHandle : void* -> "pointer"
// ListInfHandle : void* optional -> "pointer"
// SectionName : LPCSTR -> "buffer"
// Operation : SETUP_FILE_OPERATION -> "u32"
// 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 SetupRemoveSectionFromDiskSpaceListA(
    void* DiskSpace,
    void* InfHandle,
    void* ListInfHandle,
    const char* SectionName,
    uint32_t Operation,
    void* Reserved1,
    uint32_t Reserved2);
C, "SETUPAPI.dll");
// $ffi->SetupRemoveSectionFromDiskSpaceListA(DiskSpace, InfHandle, ListInfHandle, SectionName, Operation, Reserved1, Reserved2);
// DiskSpace : void*
// InfHandle : void*
// ListInfHandle : void* optional
// SectionName : LPCSTR
// Operation : SETUP_FILE_OPERATION
// 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 SetupRemoveSectionFromDiskSpaceListA(
        Pointer DiskSpace,   // void*
        Pointer InfHandle,   // void*
        Pointer ListInfHandle,   // void* optional
        String SectionName,   // LPCSTR
        int Operation,   // SETUP_FILE_OPERATION
        Pointer Reserved1,   // void* optional
        int Reserved2   // DWORD optional
    );
}
@[Link("setupapi")]
lib LibSETUPAPI
  fun SetupRemoveSectionFromDiskSpaceListA = SetupRemoveSectionFromDiskSpaceListA(
    DiskSpace : Void*,   # void*
    InfHandle : Void*,   # void*
    ListInfHandle : Void*,   # void* optional
    SectionName : UInt8*,   # LPCSTR
    Operation : UInt32,   # SETUP_FILE_OPERATION
    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 SetupRemoveSectionFromDiskSpaceListANative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Utf8>, Uint32, Pointer<Void>, Uint32);
typedef SetupRemoveSectionFromDiskSpaceListADart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Utf8>, int, Pointer<Void>, int);
final SetupRemoveSectionFromDiskSpaceListA = DynamicLibrary.open('SETUPAPI.dll')
    .lookupFunction<SetupRemoveSectionFromDiskSpaceListANative, SetupRemoveSectionFromDiskSpaceListADart>('SetupRemoveSectionFromDiskSpaceListA');
// DiskSpace : void* -> Pointer<Void>
// InfHandle : void* -> Pointer<Void>
// ListInfHandle : void* optional -> Pointer<Void>
// SectionName : LPCSTR -> Pointer<Utf8>
// Operation : SETUP_FILE_OPERATION -> Uint32
// Reserved1 : void* optional -> Pointer<Void>
// Reserved2 : DWORD optional -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function SetupRemoveSectionFromDiskSpaceListA(
  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 'SetupRemoveSectionFromDiskSpaceListA';
import Foreign
import Foreign.C.Types
import Foreign.C.String

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

let setupremovesectionfromdiskspacelista =
  foreign "SetupRemoveSectionFromDiskSpaceListA"
    ((ptr void) @-> (ptr void) @-> (ptr void) @-> string @-> uint32_t @-> (ptr void) @-> uint32_t @-> returning int32_t)
(* DiskSpace : void* -> (ptr void) *)
(* InfHandle : void* -> (ptr void) *)
(* ListInfHandle : void* optional -> (ptr void) *)
(* SectionName : LPCSTR -> string *)
(* Operation : SETUP_FILE_OPERATION -> uint32_t *)
(* 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 ("SetupRemoveSectionFromDiskSpaceListA" setup-remove-section-from-disk-space-list-a :convention :stdcall) :int32
  (disk-space :pointer)   ; void*
  (inf-handle :pointer)   ; void*
  (list-inf-handle :pointer)   ; void* optional
  (section-name :string)   ; LPCSTR
  (operation :uint32)   ; SETUP_FILE_OPERATION
  (reserved1 :pointer)   ; void* optional
  (reserved2 :uint32))   ; DWORD optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SetupRemoveSectionFromDiskSpaceListA = Win32::API::More->new('SETUPAPI',
    'BOOL SetupRemoveSectionFromDiskSpaceListA(LPVOID DiskSpace, LPVOID InfHandle, LPVOID ListInfHandle, LPCSTR SectionName, DWORD Operation, LPVOID Reserved1, DWORD Reserved2)');
# my $ret = $SetupRemoveSectionFromDiskSpaceListA->Call($DiskSpace, $InfHandle, $ListInfHandle, $SectionName, $Operation, $Reserved1, $Reserved2);
# DiskSpace : void* -> LPVOID
# InfHandle : void* -> LPVOID
# ListInfHandle : void* optional -> LPVOID
# SectionName : LPCSTR -> LPCSTR
# Operation : SETUP_FILE_OPERATION -> DWORD
# Reserved1 : void* optional -> LPVOID
# Reserved2 : DWORD optional -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

文字セット違い
公式の関連項目
使用する型