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
LayoutInfHandlevoid*inoptional
FileQueuevoid*in
SectionNameLPCSTRin
SourceRootPathLPCSTRinoptional
CopyFlagsDWORDin

戻り値の型: 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 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)。