ホーム › Devices.DeviceAndDriverInstallation › SetupIterateCabinetW
SetupIterateCabinetW
関数キャビネット内の各ファイルを列挙しコールバックに通知する。
シグネチャ
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
BOOL SetupIterateCabinetW(
LPCWSTR CabinetFile,
DWORD Reserved, // optional
PSP_FILE_CALLBACK_W MsgHandler,
void* Context
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| CabinetFile | LPCWSTR | in |
| Reserved | DWORD | optional |
| MsgHandler | PSP_FILE_CALLBACK_W | in |
| Context | void* | in |
戻り値の型: BOOL
各言語での呼び出し定義
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
BOOL SetupIterateCabinetW(
LPCWSTR CabinetFile,
DWORD Reserved, // optional
PSP_FILE_CALLBACK_W MsgHandler,
void* Context
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool SetupIterateCabinetW(
[MarshalAs(UnmanagedType.LPWStr)] string CabinetFile, // LPCWSTR
uint Reserved, // DWORD optional
IntPtr MsgHandler, // PSP_FILE_CALLBACK_W
IntPtr Context // void*
);<DllImport("SETUPAPI.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupIterateCabinetW(
<MarshalAs(UnmanagedType.LPWStr)> CabinetFile As String, ' LPCWSTR
Reserved As UInteger, ' DWORD optional
MsgHandler As IntPtr, ' PSP_FILE_CALLBACK_W
Context As IntPtr ' void*
) As Boolean
End Function' CabinetFile : LPCWSTR
' Reserved : DWORD optional
' MsgHandler : PSP_FILE_CALLBACK_W
' Context : void*
Declare PtrSafe Function SetupIterateCabinetW Lib "setupapi" ( _
ByVal CabinetFile As LongPtr, _
ByVal Reserved As Long, _
ByVal MsgHandler As LongPtr, _
ByVal Context As LongPtr) 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
SetupIterateCabinetW = ctypes.windll.setupapi.SetupIterateCabinetW
SetupIterateCabinetW.restype = wintypes.BOOL
SetupIterateCabinetW.argtypes = [
wintypes.LPCWSTR, # CabinetFile : LPCWSTR
wintypes.DWORD, # Reserved : DWORD optional
ctypes.c_void_p, # MsgHandler : PSP_FILE_CALLBACK_W
ctypes.POINTER(None), # Context : void*
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SETUPAPI.dll')
SetupIterateCabinetW = Fiddle::Function.new(
lib['SetupIterateCabinetW'],
[
Fiddle::TYPE_VOIDP, # CabinetFile : LPCWSTR
-Fiddle::TYPE_INT, # Reserved : DWORD optional
Fiddle::TYPE_VOIDP, # MsgHandler : PSP_FILE_CALLBACK_W
Fiddle::TYPE_VOIDP, # Context : void*
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "setupapi")]
extern "system" {
fn SetupIterateCabinetW(
CabinetFile: *const u16, // LPCWSTR
Reserved: u32, // DWORD optional
MsgHandler: *const core::ffi::c_void, // PSP_FILE_CALLBACK_W
Context: *mut () // void*
) -> 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 SetupIterateCabinetW([MarshalAs(UnmanagedType.LPWStr)] string CabinetFile, uint Reserved, IntPtr MsgHandler, IntPtr Context);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupIterateCabinetW' -Namespace Win32 -PassThru
# $api::SetupIterateCabinetW(CabinetFile, Reserved, MsgHandler, Context)#uselib "SETUPAPI.dll"
#func global SetupIterateCabinetW "SetupIterateCabinetW" wptr, wptr, wptr, wptr
; SetupIterateCabinetW CabinetFile, Reserved, MsgHandler, Context ; 戻り値は stat
; CabinetFile : LPCWSTR -> "wptr"
; Reserved : DWORD optional -> "wptr"
; MsgHandler : PSP_FILE_CALLBACK_W -> "wptr"
; Context : void* -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "SETUPAPI.dll"
#cfunc global SetupIterateCabinetW "SetupIterateCabinetW" wstr, int, sptr, sptr
; res = SetupIterateCabinetW(CabinetFile, Reserved, MsgHandler, Context)
; CabinetFile : LPCWSTR -> "wstr"
; Reserved : DWORD optional -> "int"
; MsgHandler : PSP_FILE_CALLBACK_W -> "sptr"
; Context : void* -> "sptr"; BOOL SetupIterateCabinetW(LPCWSTR CabinetFile, DWORD Reserved, PSP_FILE_CALLBACK_W MsgHandler, void* Context)
#uselib "SETUPAPI.dll"
#cfunc global SetupIterateCabinetW "SetupIterateCabinetW" wstr, int, intptr, intptr
; res = SetupIterateCabinetW(CabinetFile, Reserved, MsgHandler, Context)
; CabinetFile : LPCWSTR -> "wstr"
; Reserved : DWORD optional -> "int"
; MsgHandler : PSP_FILE_CALLBACK_W -> "intptr"
; Context : void* -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
procSetupIterateCabinetW = setupapi.NewProc("SetupIterateCabinetW")
)
// CabinetFile (LPCWSTR), Reserved (DWORD optional), MsgHandler (PSP_FILE_CALLBACK_W), Context (void*)
r1, _, err := procSetupIterateCabinetW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(CabinetFile))),
uintptr(Reserved),
uintptr(MsgHandler),
uintptr(Context),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetupIterateCabinetW(
CabinetFile: PWideChar; // LPCWSTR
Reserved: DWORD; // DWORD optional
MsgHandler: Pointer; // PSP_FILE_CALLBACK_W
Context: Pointer // void*
): BOOL; stdcall;
external 'SETUPAPI.dll' name 'SetupIterateCabinetW';result := DllCall("SETUPAPI\SetupIterateCabinetW"
, "WStr", CabinetFile ; LPCWSTR
, "UInt", Reserved ; DWORD optional
, "Ptr", MsgHandler ; PSP_FILE_CALLBACK_W
, "Ptr", Context ; void*
, "Int") ; return: BOOL●SetupIterateCabinetW(CabinetFile, Reserved, MsgHandler, Context) = DLL("SETUPAPI.dll", "bool SetupIterateCabinetW(char*, dword, void*, void*)")
# 呼び出し: SetupIterateCabinetW(CabinetFile, Reserved, MsgHandler, Context)
# CabinetFile : LPCWSTR -> "char*"
# Reserved : DWORD optional -> "dword"
# MsgHandler : PSP_FILE_CALLBACK_W -> "void*"
# Context : void* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。