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

SetupInstallFilesFromInfSectionA

関数
INFセクションが指定するファイルをキューに登録しコピーする。
DLLSETUPAPI.dll文字セットANSI (-A)呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

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

BOOL SetupInstallFilesFromInfSectionA(
    void* InfHandle,
    void* LayoutInfHandle,   // optional
    void* FileQueue,
    LPCSTR SectionName,
    LPCSTR SourceRootPath,   // optional
    DWORD CopyFlags
);

パラメーター

名前方向説明
InfHandlevoid*inコピー対象ファイルを記述したINFファイルのハンドル。
LayoutInfHandlevoid*inoptionalソースメディア情報を持つレイアウトINFのハンドル。NULL可。
FileQueuevoid*in操作を登録するファイルキューのハンドル。
SectionNameLPCSTRinファイル操作を列挙したINFのセクション名(ANSI)。
SourceRootPathLPCSTRinoptionalコピー元ファイルのルートパス(ANSI)。NULL可。
CopyFlagsDWORDinファイルコピー時に適用するSP_COPY_*フラグ。

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL SetupInstallFilesFromInfSectionA(
    void* InfHandle,
    void* LayoutInfHandle,   // optional
    void* FileQueue,
    LPCSTR SectionName,
    LPCSTR SourceRootPath,   // optional
    DWORD CopyFlags
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool SetupInstallFilesFromInfSectionA(
    IntPtr InfHandle,   // void*
    IntPtr LayoutInfHandle,   // void* optional
    IntPtr FileQueue,   // void*
    [MarshalAs(UnmanagedType.LPStr)] string SectionName,   // LPCSTR
    [MarshalAs(UnmanagedType.LPStr)] string SourceRootPath,   // LPCSTR optional
    uint CopyFlags   // DWORD
);
<DllImport("SETUPAPI.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupInstallFilesFromInfSectionA(
    InfHandle As IntPtr,   ' void*
    LayoutInfHandle As IntPtr,   ' void* optional
    FileQueue As IntPtr,   ' void*
    <MarshalAs(UnmanagedType.LPStr)> SectionName As String,   ' LPCSTR
    <MarshalAs(UnmanagedType.LPStr)> SourceRootPath As String,   ' LPCSTR optional
    CopyFlags As UInteger   ' DWORD
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
' InfHandle : void*
' LayoutInfHandle : void* optional
' FileQueue : void*
' SectionName : LPCSTR
' SourceRootPath : LPCSTR optional
' CopyFlags : DWORD
Declare PtrSafe Function SetupInstallFilesFromInfSectionA Lib "setupapi" ( _
    ByVal InfHandle As LongPtr, _
    ByVal LayoutInfHandle As LongPtr, _
    ByVal FileQueue As LongPtr, _
    ByVal SectionName As String, _
    ByVal SourceRootPath As String, _
    ByVal CopyFlags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SetupInstallFilesFromInfSectionA = ctypes.windll.setupapi.SetupInstallFilesFromInfSectionA
SetupInstallFilesFromInfSectionA.restype = wintypes.BOOL
SetupInstallFilesFromInfSectionA.argtypes = [
    ctypes.POINTER(None),  # InfHandle : void*
    ctypes.POINTER(None),  # LayoutInfHandle : void* optional
    ctypes.POINTER(None),  # FileQueue : void*
    wintypes.LPCSTR,  # SectionName : LPCSTR
    wintypes.LPCSTR,  # SourceRootPath : LPCSTR 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')
SetupInstallFilesFromInfSectionA = Fiddle::Function.new(
  lib['SetupInstallFilesFromInfSectionA'],
  [
    Fiddle::TYPE_VOIDP,  # InfHandle : void*
    Fiddle::TYPE_VOIDP,  # LayoutInfHandle : void* optional
    Fiddle::TYPE_VOIDP,  # FileQueue : void*
    Fiddle::TYPE_VOIDP,  # SectionName : LPCSTR
    Fiddle::TYPE_VOIDP,  # SourceRootPath : LPCSTR optional
    -Fiddle::TYPE_INT,  # CopyFlags : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "setupapi")]
extern "system" {
    fn SetupInstallFilesFromInfSectionA(
        InfHandle: *mut (),  // void*
        LayoutInfHandle: *mut (),  // void* optional
        FileQueue: *mut (),  // void*
        SectionName: *const u8,  // LPCSTR
        SourceRootPath: *const u8,  // LPCSTR 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.Ansi, SetLastError = true)]
public static extern bool SetupInstallFilesFromInfSectionA(IntPtr InfHandle, IntPtr LayoutInfHandle, IntPtr FileQueue, [MarshalAs(UnmanagedType.LPStr)] string SectionName, [MarshalAs(UnmanagedType.LPStr)] string SourceRootPath, uint CopyFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupInstallFilesFromInfSectionA' -Namespace Win32 -PassThru
# $api::SetupInstallFilesFromInfSectionA(InfHandle, LayoutInfHandle, FileQueue, SectionName, SourceRootPath, CopyFlags)
#uselib "SETUPAPI.dll"
#func global SetupInstallFilesFromInfSectionA "SetupInstallFilesFromInfSectionA" sptr, sptr, sptr, sptr, sptr, sptr
; SetupInstallFilesFromInfSectionA InfHandle, LayoutInfHandle, FileQueue, SectionName, SourceRootPath, CopyFlags   ; 戻り値は stat
; InfHandle : void* -> "sptr"
; LayoutInfHandle : void* optional -> "sptr"
; FileQueue : void* -> "sptr"
; SectionName : LPCSTR -> "sptr"
; SourceRootPath : LPCSTR optional -> "sptr"
; CopyFlags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SETUPAPI.dll"
#cfunc global SetupInstallFilesFromInfSectionA "SetupInstallFilesFromInfSectionA" sptr, sptr, sptr, str, str, int
; res = SetupInstallFilesFromInfSectionA(InfHandle, LayoutInfHandle, FileQueue, SectionName, SourceRootPath, CopyFlags)
; InfHandle : void* -> "sptr"
; LayoutInfHandle : void* optional -> "sptr"
; FileQueue : void* -> "sptr"
; SectionName : LPCSTR -> "str"
; SourceRootPath : LPCSTR optional -> "str"
; CopyFlags : DWORD -> "int"
; BOOL SetupInstallFilesFromInfSectionA(void* InfHandle, void* LayoutInfHandle, void* FileQueue, LPCSTR SectionName, LPCSTR SourceRootPath, DWORD CopyFlags)
#uselib "SETUPAPI.dll"
#cfunc global SetupInstallFilesFromInfSectionA "SetupInstallFilesFromInfSectionA" intptr, intptr, intptr, str, str, int
; res = SetupInstallFilesFromInfSectionA(InfHandle, LayoutInfHandle, FileQueue, SectionName, SourceRootPath, CopyFlags)
; InfHandle : void* -> "intptr"
; LayoutInfHandle : void* optional -> "intptr"
; FileQueue : void* -> "intptr"
; SectionName : LPCSTR -> "str"
; SourceRootPath : LPCSTR optional -> "str"
; CopyFlags : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
	procSetupInstallFilesFromInfSectionA = setupapi.NewProc("SetupInstallFilesFromInfSectionA")
)

// InfHandle (void*), LayoutInfHandle (void* optional), FileQueue (void*), SectionName (LPCSTR), SourceRootPath (LPCSTR optional), CopyFlags (DWORD)
r1, _, err := procSetupInstallFilesFromInfSectionA.Call(
	uintptr(InfHandle),
	uintptr(LayoutInfHandle),
	uintptr(FileQueue),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(SectionName))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(SourceRootPath))),
	uintptr(CopyFlags),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function SetupInstallFilesFromInfSectionA(
  InfHandle: Pointer;   // void*
  LayoutInfHandle: Pointer;   // void* optional
  FileQueue: Pointer;   // void*
  SectionName: PAnsiChar;   // LPCSTR
  SourceRootPath: PAnsiChar;   // LPCSTR optional
  CopyFlags: DWORD   // DWORD
): BOOL; stdcall;
  external 'SETUPAPI.dll' name 'SetupInstallFilesFromInfSectionA';
result := DllCall("SETUPAPI\SetupInstallFilesFromInfSectionA"
    , "Ptr", InfHandle   ; void*
    , "Ptr", LayoutInfHandle   ; void* optional
    , "Ptr", FileQueue   ; void*
    , "AStr", SectionName   ; LPCSTR
    , "AStr", SourceRootPath   ; LPCSTR optional
    , "UInt", CopyFlags   ; DWORD
    , "Int")   ; return: BOOL
●SetupInstallFilesFromInfSectionA(InfHandle, LayoutInfHandle, FileQueue, SectionName, SourceRootPath, CopyFlags) = DLL("SETUPAPI.dll", "bool SetupInstallFilesFromInfSectionA(void*, void*, void*, char*, char*, dword)")
# 呼び出し: SetupInstallFilesFromInfSectionA(InfHandle, LayoutInfHandle, FileQueue, SectionName, SourceRootPath, CopyFlags)
# InfHandle : void* -> "void*"
# LayoutInfHandle : void* optional -> "void*"
# FileQueue : void* -> "void*"
# SectionName : LPCSTR -> "char*"
# SourceRootPath : LPCSTR optional -> "char*"
# CopyFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

foreign import stdcall safe "SetupInstallFilesFromInfSectionA"
  c_SetupInstallFilesFromInfSectionA :: Ptr () -> Ptr () -> Ptr () -> CString -> CString -> Word32 -> IO CInt
-- InfHandle : void* -> Ptr ()
-- LayoutInfHandle : void* optional -> Ptr ()
-- FileQueue : void* -> Ptr ()
-- SectionName : LPCSTR -> CString
-- SourceRootPath : LPCSTR optional -> CString
-- CopyFlags : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let setupinstallfilesfrominfsectiona =
  foreign "SetupInstallFilesFromInfSectionA"
    ((ptr void) @-> (ptr void) @-> (ptr void) @-> string @-> string @-> uint32_t @-> returning int32_t)
(* InfHandle : void* -> (ptr void) *)
(* LayoutInfHandle : void* optional -> (ptr void) *)
(* FileQueue : void* -> (ptr void) *)
(* SectionName : LPCSTR -> string *)
(* SourceRootPath : LPCSTR optional -> string *)
(* 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 ("SetupInstallFilesFromInfSectionA" setup-install-files-from-inf-section-a :convention :stdcall) :int32
  (inf-handle :pointer)   ; void*
  (layout-inf-handle :pointer)   ; void* optional
  (file-queue :pointer)   ; void*
  (section-name :string)   ; LPCSTR
  (source-root-path :string)   ; LPCSTR optional
  (copy-flags :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SetupInstallFilesFromInfSectionA = Win32::API::More->new('SETUPAPI',
    'BOOL SetupInstallFilesFromInfSectionA(LPVOID InfHandle, LPVOID LayoutInfHandle, LPVOID FileQueue, LPCSTR SectionName, LPCSTR SourceRootPath, DWORD CopyFlags)');
# my $ret = $SetupInstallFilesFromInfSectionA->Call($InfHandle, $LayoutInfHandle, $FileQueue, $SectionName, $SourceRootPath, $CopyFlags);
# InfHandle : void* -> LPVOID
# LayoutInfHandle : void* optional -> LPVOID
# FileQueue : void* -> LPVOID
# SectionName : LPCSTR -> LPCSTR
# SourceRootPath : LPCSTR optional -> LPCSTR
# CopyFlags : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

文字セット違い