ホーム › Devices.DeviceAndDriverInstallation › SetupAdjustDiskSpaceListW
SetupAdjustDiskSpaceListW
関数ディスク容量リスト内の指定ドライブの空き容量を増減調整する。
シグネチャ
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
BOOL SetupAdjustDiskSpaceListW(
void* DiskSpace,
LPCWSTR DriveRoot,
LONGLONG Amount,
void* Reserved1, // optional
DWORD Reserved2 // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| DiskSpace | void* | in |
| DriveRoot | LPCWSTR | in |
| Amount | LONGLONG | in |
| Reserved1 | void* | optional |
| Reserved2 | DWORD | optional |
戻り値の型: BOOL
各言語での呼び出し定義
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
BOOL SetupAdjustDiskSpaceListW(
void* DiskSpace,
LPCWSTR DriveRoot,
LONGLONG Amount,
void* Reserved1, // optional
DWORD Reserved2 // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool SetupAdjustDiskSpaceListW(
IntPtr DiskSpace, // void*
[MarshalAs(UnmanagedType.LPWStr)] string DriveRoot, // LPCWSTR
long Amount, // LONGLONG
IntPtr Reserved1, // void* optional
uint Reserved2 // DWORD optional
);<DllImport("SETUPAPI.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupAdjustDiskSpaceListW(
DiskSpace As IntPtr, ' void*
<MarshalAs(UnmanagedType.LPWStr)> DriveRoot As String, ' LPCWSTR
Amount As Long, ' LONGLONG
Reserved1 As IntPtr, ' void* optional
Reserved2 As UInteger ' DWORD optional
) As Boolean
End Function' DiskSpace : void*
' DriveRoot : LPCWSTR
' Amount : LONGLONG
' Reserved1 : void* optional
' Reserved2 : DWORD optional
Declare PtrSafe Function SetupAdjustDiskSpaceListW Lib "setupapi" ( _
ByVal DiskSpace As LongPtr, _
ByVal DriveRoot As LongPtr, _
ByVal Amount As LongLong, _
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
SetupAdjustDiskSpaceListW = ctypes.windll.setupapi.SetupAdjustDiskSpaceListW
SetupAdjustDiskSpaceListW.restype = wintypes.BOOL
SetupAdjustDiskSpaceListW.argtypes = [
ctypes.POINTER(None), # DiskSpace : void*
wintypes.LPCWSTR, # DriveRoot : LPCWSTR
ctypes.c_longlong, # Amount : LONGLONG
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')
SetupAdjustDiskSpaceListW = Fiddle::Function.new(
lib['SetupAdjustDiskSpaceListW'],
[
Fiddle::TYPE_VOIDP, # DiskSpace : void*
Fiddle::TYPE_VOIDP, # DriveRoot : LPCWSTR
Fiddle::TYPE_LONG_LONG, # Amount : LONGLONG
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 SetupAdjustDiskSpaceListW(
DiskSpace: *mut (), // void*
DriveRoot: *const u16, // LPCWSTR
Amount: i64, // LONGLONG
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 SetupAdjustDiskSpaceListW(IntPtr DiskSpace, [MarshalAs(UnmanagedType.LPWStr)] string DriveRoot, long Amount, IntPtr Reserved1, uint Reserved2);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupAdjustDiskSpaceListW' -Namespace Win32 -PassThru
# $api::SetupAdjustDiskSpaceListW(DiskSpace, DriveRoot, Amount, Reserved1, Reserved2)#uselib "SETUPAPI.dll"
#func global SetupAdjustDiskSpaceListW "SetupAdjustDiskSpaceListW" wptr, wptr, wptr, wptr, wptr
; SetupAdjustDiskSpaceListW DiskSpace, DriveRoot, Amount, Reserved1, Reserved2 ; 戻り値は stat
; DiskSpace : void* -> "wptr"
; DriveRoot : LPCWSTR -> "wptr"
; Amount : LONGLONG -> "wptr"
; Reserved1 : void* optional -> "wptr"
; Reserved2 : DWORD optional -> "wptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "SETUPAPI.dll"
#cfunc global SetupAdjustDiskSpaceListW "SetupAdjustDiskSpaceListW" sptr, wstr, int64, sptr, int
; res = SetupAdjustDiskSpaceListW(DiskSpace, DriveRoot, Amount, Reserved1, Reserved2)
; DiskSpace : void* -> "sptr"
; DriveRoot : LPCWSTR -> "wstr"
; Amount : LONGLONG -> "int64"
; Reserved1 : void* optional -> "sptr"
; Reserved2 : DWORD optional -> "int"
; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。; BOOL SetupAdjustDiskSpaceListW(void* DiskSpace, LPCWSTR DriveRoot, LONGLONG Amount, void* Reserved1, DWORD Reserved2)
#uselib "SETUPAPI.dll"
#cfunc global SetupAdjustDiskSpaceListW "SetupAdjustDiskSpaceListW" intptr, wstr, int64, intptr, int
; res = SetupAdjustDiskSpaceListW(DiskSpace, DriveRoot, Amount, Reserved1, Reserved2)
; DiskSpace : void* -> "intptr"
; DriveRoot : LPCWSTR -> "wstr"
; Amount : LONGLONG -> "int64"
; Reserved1 : void* optional -> "intptr"
; Reserved2 : DWORD optional -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
procSetupAdjustDiskSpaceListW = setupapi.NewProc("SetupAdjustDiskSpaceListW")
)
// DiskSpace (void*), DriveRoot (LPCWSTR), Amount (LONGLONG), Reserved1 (void* optional), Reserved2 (DWORD optional)
r1, _, err := procSetupAdjustDiskSpaceListW.Call(
uintptr(DiskSpace),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(DriveRoot))),
uintptr(Amount),
uintptr(Reserved1),
uintptr(Reserved2),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetupAdjustDiskSpaceListW(
DiskSpace: Pointer; // void*
DriveRoot: PWideChar; // LPCWSTR
Amount: Int64; // LONGLONG
Reserved1: Pointer; // void* optional
Reserved2: DWORD // DWORD optional
): BOOL; stdcall;
external 'SETUPAPI.dll' name 'SetupAdjustDiskSpaceListW';result := DllCall("SETUPAPI\SetupAdjustDiskSpaceListW"
, "Ptr", DiskSpace ; void*
, "WStr", DriveRoot ; LPCWSTR
, "Int64", Amount ; LONGLONG
, "Ptr", Reserved1 ; void* optional
, "UInt", Reserved2 ; DWORD optional
, "Int") ; return: BOOL●SetupAdjustDiskSpaceListW(DiskSpace, DriveRoot, Amount, Reserved1, Reserved2) = DLL("SETUPAPI.dll", "bool SetupAdjustDiskSpaceListW(void*, char*, int64, void*, dword)")
# 呼び出し: SetupAdjustDiskSpaceListW(DiskSpace, DriveRoot, Amount, Reserved1, Reserved2)
# DiskSpace : void* -> "void*"
# DriveRoot : LPCWSTR -> "char*"
# Amount : LONGLONG -> "int64"
# Reserved1 : void* optional -> "void*"
# Reserved2 : DWORD optional -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。