ホーム › Devices.DeviceAndDriverInstallation › SetupAddInstallSectionToDiskSpaceListW
SetupAddInstallSectionToDiskSpaceListW
関数INFのインストールセクションをディスク容量リストに追加する。
シグネチャ
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
BOOL SetupAddInstallSectionToDiskSpaceListW(
void* DiskSpace,
void* InfHandle,
void* LayoutInfHandle, // optional
LPCWSTR SectionName,
void* Reserved1, // optional
DWORD Reserved2 // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| DiskSpace | void* | in | 操作を追加するディスク領域リストのハンドル。 |
| InfHandle | void* | in | インストールセクションを記述したINFファイルのハンドル。 |
| LayoutInfHandle | void* | inoptional | ファイルサイズ情報を持つレイアウトINFのハンドル。NULL可。 |
| SectionName | LPCWSTR | in | 処理対象のインストールセクション名(Unicode)。 |
| Reserved1 | void* | optional | 予約済み。NULLを指定する必要がある。 |
| Reserved2 | DWORD | optional | 予約済み。0を指定する必要がある。 |
戻り値の型: BOOL
各言語での呼び出し定義
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
BOOL SetupAddInstallSectionToDiskSpaceListW(
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 SetupAddInstallSectionToDiskSpaceListW(
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 SetupAddInstallSectionToDiskSpaceListW(
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 <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' DiskSpace : void*
' InfHandle : void*
' LayoutInfHandle : void* optional
' SectionName : LPCWSTR
' Reserved1 : void* optional
' Reserved2 : DWORD optional
Declare PtrSafe Function SetupAddInstallSectionToDiskSpaceListW 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
SetupAddInstallSectionToDiskSpaceListW = ctypes.windll.setupapi.SetupAddInstallSectionToDiskSpaceListW
SetupAddInstallSectionToDiskSpaceListW.restype = wintypes.BOOL
SetupAddInstallSectionToDiskSpaceListW.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')
SetupAddInstallSectionToDiskSpaceListW = Fiddle::Function.new(
lib['SetupAddInstallSectionToDiskSpaceListW'],
[
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 SetupAddInstallSectionToDiskSpaceListW(
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 SetupAddInstallSectionToDiskSpaceListW(IntPtr DiskSpace, IntPtr InfHandle, IntPtr LayoutInfHandle, [MarshalAs(UnmanagedType.LPWStr)] string SectionName, IntPtr Reserved1, uint Reserved2);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupAddInstallSectionToDiskSpaceListW' -Namespace Win32 -PassThru
# $api::SetupAddInstallSectionToDiskSpaceListW(DiskSpace, InfHandle, LayoutInfHandle, SectionName, Reserved1, Reserved2)#uselib "SETUPAPI.dll"
#func global SetupAddInstallSectionToDiskSpaceListW "SetupAddInstallSectionToDiskSpaceListW" wptr, wptr, wptr, wptr, wptr, wptr
; SetupAddInstallSectionToDiskSpaceListW 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 SetupAddInstallSectionToDiskSpaceListW "SetupAddInstallSectionToDiskSpaceListW" sptr, sptr, sptr, wstr, sptr, int
; res = SetupAddInstallSectionToDiskSpaceListW(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 SetupAddInstallSectionToDiskSpaceListW(void* DiskSpace, void* InfHandle, void* LayoutInfHandle, LPCWSTR SectionName, void* Reserved1, DWORD Reserved2)
#uselib "SETUPAPI.dll"
#cfunc global SetupAddInstallSectionToDiskSpaceListW "SetupAddInstallSectionToDiskSpaceListW" intptr, intptr, intptr, wstr, intptr, int
; res = SetupAddInstallSectionToDiskSpaceListW(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")
procSetupAddInstallSectionToDiskSpaceListW = setupapi.NewProc("SetupAddInstallSectionToDiskSpaceListW")
)
// DiskSpace (void*), InfHandle (void*), LayoutInfHandle (void* optional), SectionName (LPCWSTR), Reserved1 (void* optional), Reserved2 (DWORD optional)
r1, _, err := procSetupAddInstallSectionToDiskSpaceListW.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 // BOOLfunction SetupAddInstallSectionToDiskSpaceListW(
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 'SetupAddInstallSectionToDiskSpaceListW';result := DllCall("SETUPAPI\SetupAddInstallSectionToDiskSpaceListW"
, "Ptr", DiskSpace ; void*
, "Ptr", InfHandle ; void*
, "Ptr", LayoutInfHandle ; void* optional
, "WStr", SectionName ; LPCWSTR
, "Ptr", Reserved1 ; void* optional
, "UInt", Reserved2 ; DWORD optional
, "Int") ; return: BOOL●SetupAddInstallSectionToDiskSpaceListW(DiskSpace, InfHandle, LayoutInfHandle, SectionName, Reserved1, Reserved2) = DLL("SETUPAPI.dll", "bool SetupAddInstallSectionToDiskSpaceListW(void*, void*, void*, char*, void*, dword)")
# 呼び出し: SetupAddInstallSectionToDiskSpaceListW(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 版の利用を推奨。const std = @import("std");
extern "setupapi" fn SetupAddInstallSectionToDiskSpaceListW(
DiskSpace: ?*anyopaque, // void*
InfHandle: ?*anyopaque, // void*
LayoutInfHandle: ?*anyopaque, // void* optional
SectionName: [*c]const u16, // LPCWSTR
Reserved1: ?*anyopaque, // void* optional
Reserved2: u32 // DWORD optional
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc SetupAddInstallSectionToDiskSpaceListW(
DiskSpace: pointer, # void*
InfHandle: pointer, # void*
LayoutInfHandle: pointer, # void* optional
SectionName: WideCString, # LPCWSTR
Reserved1: pointer, # void* optional
Reserved2: uint32 # DWORD optional
): int32 {.importc: "SetupAddInstallSectionToDiskSpaceListW", stdcall, dynlib: "SETUPAPI.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "setupapi");
extern(Windows)
int SetupAddInstallSectionToDiskSpaceListW(
void* DiskSpace, // void*
void* InfHandle, // void*
void* LayoutInfHandle, // void* optional
const(wchar)* SectionName, // LPCWSTR
void* Reserved1, // void* optional
uint Reserved2 // DWORD optional
);ccall((:SetupAddInstallSectionToDiskSpaceListW, "SETUPAPI.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Cwstring, Ptr{Cvoid}, UInt32),
DiskSpace, InfHandle, LayoutInfHandle, SectionName, Reserved1, Reserved2)
# DiskSpace : void* -> Ptr{Cvoid}
# InfHandle : void* -> Ptr{Cvoid}
# LayoutInfHandle : void* optional -> Ptr{Cvoid}
# SectionName : LPCWSTR -> Cwstring
# Reserved1 : void* optional -> Ptr{Cvoid}
# Reserved2 : DWORD optional -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
int32_t SetupAddInstallSectionToDiskSpaceListW(
void* DiskSpace,
void* InfHandle,
void* LayoutInfHandle,
const uint16_t* SectionName,
void* Reserved1,
uint32_t Reserved2);
]]
local setupapi = ffi.load("setupapi")
-- setupapi.SetupAddInstallSectionToDiskSpaceListW(DiskSpace, InfHandle, LayoutInfHandle, SectionName, Reserved1, Reserved2)
-- DiskSpace : void*
-- InfHandle : void*
-- LayoutInfHandle : void* optional
-- SectionName : LPCWSTR
-- Reserved1 : void* optional
-- Reserved2 : DWORD optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('SETUPAPI.dll');
const SetupAddInstallSectionToDiskSpaceListW = lib.func('__stdcall', 'SetupAddInstallSectionToDiskSpaceListW', 'int32_t', ['void *', 'void *', 'void *', 'str16', 'void *', 'uint32_t']);
// SetupAddInstallSectionToDiskSpaceListW(DiskSpace, InfHandle, LayoutInfHandle, SectionName, Reserved1, Reserved2)
// DiskSpace : void* -> 'void *'
// InfHandle : void* -> 'void *'
// LayoutInfHandle : void* optional -> 'void *'
// SectionName : LPCWSTR -> 'str16'
// Reserved1 : void* optional -> 'void *'
// Reserved2 : DWORD optional -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("SETUPAPI.dll", {
SetupAddInstallSectionToDiskSpaceListW: { parameters: ["pointer", "pointer", "pointer", "buffer", "pointer", "u32"], result: "i32" },
});
// lib.symbols.SetupAddInstallSectionToDiskSpaceListW(DiskSpace, InfHandle, LayoutInfHandle, SectionName, Reserved1, Reserved2)
// DiskSpace : void* -> "pointer"
// InfHandle : void* -> "pointer"
// LayoutInfHandle : void* optional -> "pointer"
// SectionName : LPCWSTR -> "buffer"
// Reserved1 : void* optional -> "pointer"
// Reserved2 : DWORD optional -> "u32"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t SetupAddInstallSectionToDiskSpaceListW(
void* DiskSpace,
void* InfHandle,
void* LayoutInfHandle,
const uint16_t* SectionName,
void* Reserved1,
uint32_t Reserved2);
C, "SETUPAPI.dll");
// $ffi->SetupAddInstallSectionToDiskSpaceListW(DiskSpace, InfHandle, LayoutInfHandle, SectionName, Reserved1, Reserved2);
// DiskSpace : void*
// InfHandle : void*
// LayoutInfHandle : void* optional
// SectionName : LPCWSTR
// 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.UNICODE_OPTIONS);
boolean SetupAddInstallSectionToDiskSpaceListW(
Pointer DiskSpace, // void*
Pointer InfHandle, // void*
Pointer LayoutInfHandle, // void* optional
WString SectionName, // LPCWSTR
Pointer Reserved1, // void* optional
int Reserved2 // DWORD optional
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("setupapi")]
lib LibSETUPAPI
fun SetupAddInstallSectionToDiskSpaceListW = SetupAddInstallSectionToDiskSpaceListW(
DiskSpace : Void*, # void*
InfHandle : Void*, # void*
LayoutInfHandle : Void*, # void* optional
SectionName : UInt16*, # LPCWSTR
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 SetupAddInstallSectionToDiskSpaceListWNative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Utf16>, Pointer<Void>, Uint32);
typedef SetupAddInstallSectionToDiskSpaceListWDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Utf16>, Pointer<Void>, int);
final SetupAddInstallSectionToDiskSpaceListW = DynamicLibrary.open('SETUPAPI.dll')
.lookupFunction<SetupAddInstallSectionToDiskSpaceListWNative, SetupAddInstallSectionToDiskSpaceListWDart>('SetupAddInstallSectionToDiskSpaceListW');
// DiskSpace : void* -> Pointer<Void>
// InfHandle : void* -> Pointer<Void>
// LayoutInfHandle : void* optional -> Pointer<Void>
// SectionName : LPCWSTR -> Pointer<Utf16>
// Reserved1 : void* optional -> Pointer<Void>
// Reserved2 : DWORD optional -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SetupAddInstallSectionToDiskSpaceListW(
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 'SetupAddInstallSectionToDiskSpaceListW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SetupAddInstallSectionToDiskSpaceListW"
c_SetupAddInstallSectionToDiskSpaceListW :: Ptr () -> Ptr () -> Ptr () -> CWString -> Ptr () -> Word32 -> IO CInt
-- DiskSpace : void* -> Ptr ()
-- InfHandle : void* -> Ptr ()
-- LayoutInfHandle : void* optional -> Ptr ()
-- SectionName : LPCWSTR -> CWString
-- Reserved1 : void* optional -> Ptr ()
-- Reserved2 : DWORD optional -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let setupaddinstallsectiontodiskspacelistw =
foreign "SetupAddInstallSectionToDiskSpaceListW"
((ptr void) @-> (ptr void) @-> (ptr void) @-> (ptr uint16_t) @-> (ptr void) @-> uint32_t @-> returning int32_t)
(* DiskSpace : void* -> (ptr void) *)
(* InfHandle : void* -> (ptr void) *)
(* LayoutInfHandle : void* optional -> (ptr void) *)
(* SectionName : LPCWSTR -> (ptr uint16_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 ("SetupAddInstallSectionToDiskSpaceListW" setup-add-install-section-to-disk-space-list-w :convention :stdcall) :int32
(disk-space :pointer) ; void*
(inf-handle :pointer) ; void*
(layout-inf-handle :pointer) ; void* optional
(section-name (:string :encoding :utf-16le)) ; LPCWSTR
(reserved1 :pointer) ; void* optional
(reserved2 :uint32)) ; DWORD optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SetupAddInstallSectionToDiskSpaceListW = Win32::API::More->new('SETUPAPI',
'BOOL SetupAddInstallSectionToDiskSpaceListW(LPVOID DiskSpace, LPVOID InfHandle, LPVOID LayoutInfHandle, LPCWSTR SectionName, LPVOID Reserved1, DWORD Reserved2)');
# my $ret = $SetupAddInstallSectionToDiskSpaceListW->Call($DiskSpace, $InfHandle, $LayoutInfHandle, $SectionName, $Reserved1, $Reserved2);
# DiskSpace : void* -> LPVOID
# InfHandle : void* -> LPVOID
# LayoutInfHandle : void* optional -> LPVOID
# SectionName : LPCWSTR -> LPCWSTR
# Reserved1 : void* optional -> LPVOID
# Reserved2 : DWORD optional -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f SetupAddInstallSectionToDiskSpaceListA (ANSI版) — INFのインストールセクションをディスク容量リストに追加する。