ホーム › Devices.DeviceAndDriverInstallation › SetupInstallFilesFromInfSectionW
SetupInstallFilesFromInfSectionW
関数INFセクションが指定するファイルをキューに登録しコピーする。
シグネチャ
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
BOOL SetupInstallFilesFromInfSectionW(
void* InfHandle,
void* LayoutInfHandle, // optional
void* FileQueue,
LPCWSTR SectionName,
LPCWSTR SourceRootPath, // optional
DWORD CopyFlags
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| InfHandle | void* | in | コピー対象ファイルを記述したINFファイルのハンドル。 |
| LayoutInfHandle | void* | inoptional | ソースメディア情報を持つレイアウトINFのハンドル。NULL可。 |
| FileQueue | void* | in | 操作を登録するファイルキューのハンドル。 |
| SectionName | LPCWSTR | in | ファイル操作を列挙したINFのセクション名(Unicode)。 |
| SourceRootPath | LPCWSTR | inoptional | コピー元ファイルのルートパス(Unicode)。NULL可。 |
| CopyFlags | DWORD | in | ファイルコピー時に適用するSP_COPY_*フラグ。 |
戻り値の型: BOOL
各言語での呼び出し定義
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
BOOL SetupInstallFilesFromInfSectionW(
void* InfHandle,
void* LayoutInfHandle, // optional
void* FileQueue,
LPCWSTR SectionName,
LPCWSTR SourceRootPath, // optional
DWORD CopyFlags
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool SetupInstallFilesFromInfSectionW(
IntPtr InfHandle, // void*
IntPtr LayoutInfHandle, // void* optional
IntPtr FileQueue, // void*
[MarshalAs(UnmanagedType.LPWStr)] string SectionName, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string SourceRootPath, // LPCWSTR optional
uint CopyFlags // DWORD
);<DllImport("SETUPAPI.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupInstallFilesFromInfSectionW(
InfHandle As IntPtr, ' void*
LayoutInfHandle As IntPtr, ' void* optional
FileQueue As IntPtr, ' void*
<MarshalAs(UnmanagedType.LPWStr)> SectionName As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> SourceRootPath As String, ' LPCWSTR optional
CopyFlags As UInteger ' DWORD
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' InfHandle : void*
' LayoutInfHandle : void* optional
' FileQueue : void*
' SectionName : LPCWSTR
' SourceRootPath : LPCWSTR optional
' CopyFlags : DWORD
Declare PtrSafe Function SetupInstallFilesFromInfSectionW Lib "setupapi" ( _
ByVal InfHandle As LongPtr, _
ByVal LayoutInfHandle As LongPtr, _
ByVal FileQueue As LongPtr, _
ByVal SectionName As LongPtr, _
ByVal SourceRootPath As LongPtr, _
ByVal CopyFlags 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
SetupInstallFilesFromInfSectionW = ctypes.windll.setupapi.SetupInstallFilesFromInfSectionW
SetupInstallFilesFromInfSectionW.restype = wintypes.BOOL
SetupInstallFilesFromInfSectionW.argtypes = [
ctypes.POINTER(None), # InfHandle : void*
ctypes.POINTER(None), # LayoutInfHandle : void* optional
ctypes.POINTER(None), # FileQueue : void*
wintypes.LPCWSTR, # SectionName : LPCWSTR
wintypes.LPCWSTR, # SourceRootPath : LPCWSTR optional
wintypes.DWORD, # CopyFlags : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SETUPAPI.dll')
SetupInstallFilesFromInfSectionW = Fiddle::Function.new(
lib['SetupInstallFilesFromInfSectionW'],
[
Fiddle::TYPE_VOIDP, # InfHandle : void*
Fiddle::TYPE_VOIDP, # LayoutInfHandle : void* optional
Fiddle::TYPE_VOIDP, # FileQueue : void*
Fiddle::TYPE_VOIDP, # SectionName : LPCWSTR
Fiddle::TYPE_VOIDP, # SourceRootPath : LPCWSTR optional
-Fiddle::TYPE_INT, # CopyFlags : DWORD
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "setupapi")]
extern "system" {
fn SetupInstallFilesFromInfSectionW(
InfHandle: *mut (), // void*
LayoutInfHandle: *mut (), // void* optional
FileQueue: *mut (), // void*
SectionName: *const u16, // LPCWSTR
SourceRootPath: *const u16, // LPCWSTR optional
CopyFlags: u32 // DWORD
) -> 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 SetupInstallFilesFromInfSectionW(IntPtr InfHandle, IntPtr LayoutInfHandle, IntPtr FileQueue, [MarshalAs(UnmanagedType.LPWStr)] string SectionName, [MarshalAs(UnmanagedType.LPWStr)] string SourceRootPath, uint CopyFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupInstallFilesFromInfSectionW' -Namespace Win32 -PassThru
# $api::SetupInstallFilesFromInfSectionW(InfHandle, LayoutInfHandle, FileQueue, SectionName, SourceRootPath, CopyFlags)#uselib "SETUPAPI.dll"
#func global SetupInstallFilesFromInfSectionW "SetupInstallFilesFromInfSectionW" wptr, wptr, wptr, wptr, wptr, wptr
; SetupInstallFilesFromInfSectionW InfHandle, LayoutInfHandle, FileQueue, SectionName, SourceRootPath, CopyFlags ; 戻り値は stat
; InfHandle : void* -> "wptr"
; LayoutInfHandle : void* optional -> "wptr"
; FileQueue : void* -> "wptr"
; SectionName : LPCWSTR -> "wptr"
; SourceRootPath : LPCWSTR optional -> "wptr"
; CopyFlags : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "SETUPAPI.dll"
#cfunc global SetupInstallFilesFromInfSectionW "SetupInstallFilesFromInfSectionW" sptr, sptr, sptr, wstr, wstr, int
; res = SetupInstallFilesFromInfSectionW(InfHandle, LayoutInfHandle, FileQueue, SectionName, SourceRootPath, CopyFlags)
; InfHandle : void* -> "sptr"
; LayoutInfHandle : void* optional -> "sptr"
; FileQueue : void* -> "sptr"
; SectionName : LPCWSTR -> "wstr"
; SourceRootPath : LPCWSTR optional -> "wstr"
; CopyFlags : DWORD -> "int"; BOOL SetupInstallFilesFromInfSectionW(void* InfHandle, void* LayoutInfHandle, void* FileQueue, LPCWSTR SectionName, LPCWSTR SourceRootPath, DWORD CopyFlags)
#uselib "SETUPAPI.dll"
#cfunc global SetupInstallFilesFromInfSectionW "SetupInstallFilesFromInfSectionW" intptr, intptr, intptr, wstr, wstr, int
; res = SetupInstallFilesFromInfSectionW(InfHandle, LayoutInfHandle, FileQueue, SectionName, SourceRootPath, CopyFlags)
; InfHandle : void* -> "intptr"
; LayoutInfHandle : void* optional -> "intptr"
; FileQueue : void* -> "intptr"
; SectionName : LPCWSTR -> "wstr"
; SourceRootPath : LPCWSTR optional -> "wstr"
; CopyFlags : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
procSetupInstallFilesFromInfSectionW = setupapi.NewProc("SetupInstallFilesFromInfSectionW")
)
// InfHandle (void*), LayoutInfHandle (void* optional), FileQueue (void*), SectionName (LPCWSTR), SourceRootPath (LPCWSTR optional), CopyFlags (DWORD)
r1, _, err := procSetupInstallFilesFromInfSectionW.Call(
uintptr(InfHandle),
uintptr(LayoutInfHandle),
uintptr(FileQueue),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(SectionName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(SourceRootPath))),
uintptr(CopyFlags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetupInstallFilesFromInfSectionW(
InfHandle: Pointer; // void*
LayoutInfHandle: Pointer; // void* optional
FileQueue: Pointer; // void*
SectionName: PWideChar; // LPCWSTR
SourceRootPath: PWideChar; // LPCWSTR optional
CopyFlags: DWORD // DWORD
): BOOL; stdcall;
external 'SETUPAPI.dll' name 'SetupInstallFilesFromInfSectionW';result := DllCall("SETUPAPI\SetupInstallFilesFromInfSectionW"
, "Ptr", InfHandle ; void*
, "Ptr", LayoutInfHandle ; void* optional
, "Ptr", FileQueue ; void*
, "WStr", SectionName ; LPCWSTR
, "WStr", SourceRootPath ; LPCWSTR optional
, "UInt", CopyFlags ; DWORD
, "Int") ; return: BOOL●SetupInstallFilesFromInfSectionW(InfHandle, LayoutInfHandle, FileQueue, SectionName, SourceRootPath, CopyFlags) = DLL("SETUPAPI.dll", "bool SetupInstallFilesFromInfSectionW(void*, void*, void*, char*, char*, dword)")
# 呼び出し: SetupInstallFilesFromInfSectionW(InfHandle, LayoutInfHandle, FileQueue, SectionName, SourceRootPath, CopyFlags)
# InfHandle : void* -> "void*"
# LayoutInfHandle : void* optional -> "void*"
# FileQueue : void* -> "void*"
# SectionName : LPCWSTR -> "char*"
# SourceRootPath : LPCWSTR optional -> "char*"
# CopyFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "setupapi" fn SetupInstallFilesFromInfSectionW(
InfHandle: ?*anyopaque, // void*
LayoutInfHandle: ?*anyopaque, // void* optional
FileQueue: ?*anyopaque, // void*
SectionName: [*c]const u16, // LPCWSTR
SourceRootPath: [*c]const u16, // LPCWSTR optional
CopyFlags: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc SetupInstallFilesFromInfSectionW(
InfHandle: pointer, # void*
LayoutInfHandle: pointer, # void* optional
FileQueue: pointer, # void*
SectionName: WideCString, # LPCWSTR
SourceRootPath: WideCString, # LPCWSTR optional
CopyFlags: uint32 # DWORD
): int32 {.importc: "SetupInstallFilesFromInfSectionW", stdcall, dynlib: "SETUPAPI.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "setupapi");
extern(Windows)
int SetupInstallFilesFromInfSectionW(
void* InfHandle, // void*
void* LayoutInfHandle, // void* optional
void* FileQueue, // void*
const(wchar)* SectionName, // LPCWSTR
const(wchar)* SourceRootPath, // LPCWSTR optional
uint CopyFlags // DWORD
);ccall((:SetupInstallFilesFromInfSectionW, "SETUPAPI.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Cwstring, Cwstring, UInt32),
InfHandle, LayoutInfHandle, FileQueue, SectionName, SourceRootPath, CopyFlags)
# InfHandle : void* -> Ptr{Cvoid}
# LayoutInfHandle : void* optional -> Ptr{Cvoid}
# FileQueue : void* -> Ptr{Cvoid}
# SectionName : LPCWSTR -> Cwstring
# SourceRootPath : LPCWSTR optional -> Cwstring
# CopyFlags : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
int32_t SetupInstallFilesFromInfSectionW(
void* InfHandle,
void* LayoutInfHandle,
void* FileQueue,
const uint16_t* SectionName,
const uint16_t* SourceRootPath,
uint32_t CopyFlags);
]]
local setupapi = ffi.load("setupapi")
-- setupapi.SetupInstallFilesFromInfSectionW(InfHandle, LayoutInfHandle, FileQueue, SectionName, SourceRootPath, CopyFlags)
-- InfHandle : void*
-- LayoutInfHandle : void* optional
-- FileQueue : void*
-- SectionName : LPCWSTR
-- SourceRootPath : LPCWSTR optional
-- CopyFlags : DWORD
-- 構造体/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 SetupInstallFilesFromInfSectionW = lib.func('__stdcall', 'SetupInstallFilesFromInfSectionW', 'int32_t', ['void *', 'void *', 'void *', 'str16', 'str16', 'uint32_t']);
// SetupInstallFilesFromInfSectionW(InfHandle, LayoutInfHandle, FileQueue, SectionName, SourceRootPath, CopyFlags)
// InfHandle : void* -> 'void *'
// LayoutInfHandle : void* optional -> 'void *'
// FileQueue : void* -> 'void *'
// SectionName : LPCWSTR -> 'str16'
// SourceRootPath : LPCWSTR optional -> 'str16'
// CopyFlags : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("SETUPAPI.dll", {
SetupInstallFilesFromInfSectionW: { parameters: ["pointer", "pointer", "pointer", "buffer", "buffer", "u32"], result: "i32" },
});
// lib.symbols.SetupInstallFilesFromInfSectionW(InfHandle, LayoutInfHandle, FileQueue, SectionName, SourceRootPath, CopyFlags)
// InfHandle : void* -> "pointer"
// LayoutInfHandle : void* optional -> "pointer"
// FileQueue : void* -> "pointer"
// SectionName : LPCWSTR -> "buffer"
// SourceRootPath : LPCWSTR optional -> "buffer"
// CopyFlags : DWORD -> "u32"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t SetupInstallFilesFromInfSectionW(
void* InfHandle,
void* LayoutInfHandle,
void* FileQueue,
const uint16_t* SectionName,
const uint16_t* SourceRootPath,
uint32_t CopyFlags);
C, "SETUPAPI.dll");
// $ffi->SetupInstallFilesFromInfSectionW(InfHandle, LayoutInfHandle, FileQueue, SectionName, SourceRootPath, CopyFlags);
// InfHandle : void*
// LayoutInfHandle : void* optional
// FileQueue : void*
// SectionName : LPCWSTR
// SourceRootPath : LPCWSTR optional
// CopyFlags : DWORD
// 構造体/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 SetupInstallFilesFromInfSectionW(
Pointer InfHandle, // void*
Pointer LayoutInfHandle, // void* optional
Pointer FileQueue, // void*
WString SectionName, // LPCWSTR
WString SourceRootPath, // LPCWSTR optional
int CopyFlags // DWORD
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("setupapi")]
lib LibSETUPAPI
fun SetupInstallFilesFromInfSectionW = SetupInstallFilesFromInfSectionW(
InfHandle : Void*, # void*
LayoutInfHandle : Void*, # void* optional
FileQueue : Void*, # void*
SectionName : UInt16*, # LPCWSTR
SourceRootPath : UInt16*, # LPCWSTR optional
CopyFlags : UInt32 # DWORD
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SetupInstallFilesFromInfSectionWNative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, Uint32);
typedef SetupInstallFilesFromInfSectionWDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, int);
final SetupInstallFilesFromInfSectionW = DynamicLibrary.open('SETUPAPI.dll')
.lookupFunction<SetupInstallFilesFromInfSectionWNative, SetupInstallFilesFromInfSectionWDart>('SetupInstallFilesFromInfSectionW');
// InfHandle : void* -> Pointer<Void>
// LayoutInfHandle : void* optional -> Pointer<Void>
// FileQueue : void* -> Pointer<Void>
// SectionName : LPCWSTR -> Pointer<Utf16>
// SourceRootPath : LPCWSTR optional -> Pointer<Utf16>
// CopyFlags : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SetupInstallFilesFromInfSectionW(
InfHandle: Pointer; // void*
LayoutInfHandle: Pointer; // void* optional
FileQueue: Pointer; // void*
SectionName: PWideChar; // LPCWSTR
SourceRootPath: PWideChar; // LPCWSTR optional
CopyFlags: DWORD // DWORD
): BOOL; stdcall;
external 'SETUPAPI.dll' name 'SetupInstallFilesFromInfSectionW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SetupInstallFilesFromInfSectionW"
c_SetupInstallFilesFromInfSectionW :: Ptr () -> Ptr () -> Ptr () -> CWString -> CWString -> Word32 -> IO CInt
-- InfHandle : void* -> Ptr ()
-- LayoutInfHandle : void* optional -> Ptr ()
-- FileQueue : void* -> Ptr ()
-- SectionName : LPCWSTR -> CWString
-- SourceRootPath : LPCWSTR optional -> CWString
-- CopyFlags : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let setupinstallfilesfrominfsectionw =
foreign "SetupInstallFilesFromInfSectionW"
((ptr void) @-> (ptr void) @-> (ptr void) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> uint32_t @-> returning int32_t)
(* InfHandle : void* -> (ptr void) *)
(* LayoutInfHandle : void* optional -> (ptr void) *)
(* FileQueue : void* -> (ptr void) *)
(* SectionName : LPCWSTR -> (ptr uint16_t) *)
(* SourceRootPath : LPCWSTR optional -> (ptr uint16_t) *)
(* CopyFlags : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library setupapi (t "SETUPAPI.dll"))
(cffi:use-foreign-library setupapi)
(cffi:defcfun ("SetupInstallFilesFromInfSectionW" setup-install-files-from-inf-section-w :convention :stdcall) :int32
(inf-handle :pointer) ; void*
(layout-inf-handle :pointer) ; void* optional
(file-queue :pointer) ; void*
(section-name (:string :encoding :utf-16le)) ; LPCWSTR
(source-root-path (:string :encoding :utf-16le)) ; LPCWSTR optional
(copy-flags :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SetupInstallFilesFromInfSectionW = Win32::API::More->new('SETUPAPI',
'BOOL SetupInstallFilesFromInfSectionW(LPVOID InfHandle, LPVOID LayoutInfHandle, LPVOID FileQueue, LPCWSTR SectionName, LPCWSTR SourceRootPath, DWORD CopyFlags)');
# my $ret = $SetupInstallFilesFromInfSectionW->Call($InfHandle, $LayoutInfHandle, $FileQueue, $SectionName, $SourceRootPath, $CopyFlags);
# InfHandle : void* -> LPVOID
# LayoutInfHandle : void* optional -> LPVOID
# FileQueue : void* -> LPVOID
# SectionName : LPCWSTR -> LPCWSTR
# SourceRootPath : LPCWSTR optional -> LPCWSTR
# CopyFlags : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f SetupInstallFilesFromInfSectionA (ANSI版) — INFセクションが指定するファイルをキューに登録しコピーする。