ホーム › Devices.DeviceAndDriverInstallation › SetupInstallFromInfSectionA
SetupInstallFromInfSectionA
関数INFのセクションに従いファイルコピーやレジストリ設定を実行する。
シグネチャ
// SETUPAPI.dll (ANSI / -A)
#include <windows.h>
BOOL SetupInstallFromInfSectionA(
HWND Owner, // optional
void* InfHandle,
LPCSTR SectionName,
DWORD Flags,
HKEY RelativeKeyRoot, // optional
LPCSTR SourceRootPath, // optional
DWORD CopyFlags,
PSP_FILE_CALLBACK_A MsgHandler, // optional
void* Context, // optional
HDEVINFO DeviceInfoSet, // optional
SP_DEVINFO_DATA* DeviceInfoData // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| Owner | HWND | inoptional |
| InfHandle | void* | in |
| SectionName | LPCSTR | in |
| Flags | DWORD | in |
| RelativeKeyRoot | HKEY | inoptional |
| SourceRootPath | LPCSTR | inoptional |
| CopyFlags | DWORD | in |
| MsgHandler | PSP_FILE_CALLBACK_A | inoptional |
| Context | void* | inoptional |
| DeviceInfoSet | HDEVINFO | inoptional |
| DeviceInfoData | SP_DEVINFO_DATA* | inoptional |
戻り値の型: BOOL
各言語での呼び出し定義
// SETUPAPI.dll (ANSI / -A)
#include <windows.h>
BOOL SetupInstallFromInfSectionA(
HWND Owner, // optional
void* InfHandle,
LPCSTR SectionName,
DWORD Flags,
HKEY RelativeKeyRoot, // optional
LPCSTR SourceRootPath, // optional
DWORD CopyFlags,
PSP_FILE_CALLBACK_A MsgHandler, // optional
void* Context, // optional
HDEVINFO DeviceInfoSet, // optional
SP_DEVINFO_DATA* DeviceInfoData // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool SetupInstallFromInfSectionA(
IntPtr Owner, // HWND optional
IntPtr InfHandle, // void*
[MarshalAs(UnmanagedType.LPStr)] string SectionName, // LPCSTR
uint Flags, // DWORD
IntPtr RelativeKeyRoot, // HKEY optional
[MarshalAs(UnmanagedType.LPStr)] string SourceRootPath, // LPCSTR optional
uint CopyFlags, // DWORD
IntPtr MsgHandler, // PSP_FILE_CALLBACK_A optional
IntPtr Context, // void* optional
IntPtr DeviceInfoSet, // HDEVINFO optional
IntPtr DeviceInfoData // SP_DEVINFO_DATA* optional
);<DllImport("SETUPAPI.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupInstallFromInfSectionA(
Owner As IntPtr, ' HWND optional
InfHandle As IntPtr, ' void*
<MarshalAs(UnmanagedType.LPStr)> SectionName As String, ' LPCSTR
Flags As UInteger, ' DWORD
RelativeKeyRoot As IntPtr, ' HKEY optional
<MarshalAs(UnmanagedType.LPStr)> SourceRootPath As String, ' LPCSTR optional
CopyFlags As UInteger, ' DWORD
MsgHandler As IntPtr, ' PSP_FILE_CALLBACK_A optional
Context As IntPtr, ' void* optional
DeviceInfoSet As IntPtr, ' HDEVINFO optional
DeviceInfoData As IntPtr ' SP_DEVINFO_DATA* optional
) As Boolean
End Function' Owner : HWND optional
' InfHandle : void*
' SectionName : LPCSTR
' Flags : DWORD
' RelativeKeyRoot : HKEY optional
' SourceRootPath : LPCSTR optional
' CopyFlags : DWORD
' MsgHandler : PSP_FILE_CALLBACK_A optional
' Context : void* optional
' DeviceInfoSet : HDEVINFO optional
' DeviceInfoData : SP_DEVINFO_DATA* optional
Declare PtrSafe Function SetupInstallFromInfSectionA Lib "setupapi" ( _
ByVal Owner As LongPtr, _
ByVal InfHandle As LongPtr, _
ByVal SectionName As String, _
ByVal Flags As Long, _
ByVal RelativeKeyRoot As LongPtr, _
ByVal SourceRootPath As String, _
ByVal CopyFlags As Long, _
ByVal MsgHandler As LongPtr, _
ByVal Context As LongPtr, _
ByVal DeviceInfoSet As LongPtr, _
ByVal DeviceInfoData As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetupInstallFromInfSectionA = ctypes.windll.setupapi.SetupInstallFromInfSectionA
SetupInstallFromInfSectionA.restype = wintypes.BOOL
SetupInstallFromInfSectionA.argtypes = [
wintypes.HANDLE, # Owner : HWND optional
ctypes.POINTER(None), # InfHandle : void*
wintypes.LPCSTR, # SectionName : LPCSTR
wintypes.DWORD, # Flags : DWORD
wintypes.HANDLE, # RelativeKeyRoot : HKEY optional
wintypes.LPCSTR, # SourceRootPath : LPCSTR optional
wintypes.DWORD, # CopyFlags : DWORD
ctypes.c_void_p, # MsgHandler : PSP_FILE_CALLBACK_A optional
ctypes.POINTER(None), # Context : void* optional
ctypes.c_ssize_t, # DeviceInfoSet : HDEVINFO optional
ctypes.c_void_p, # DeviceInfoData : SP_DEVINFO_DATA* optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SETUPAPI.dll')
SetupInstallFromInfSectionA = Fiddle::Function.new(
lib['SetupInstallFromInfSectionA'],
[
Fiddle::TYPE_VOIDP, # Owner : HWND optional
Fiddle::TYPE_VOIDP, # InfHandle : void*
Fiddle::TYPE_VOIDP, # SectionName : LPCSTR
-Fiddle::TYPE_INT, # Flags : DWORD
Fiddle::TYPE_VOIDP, # RelativeKeyRoot : HKEY optional
Fiddle::TYPE_VOIDP, # SourceRootPath : LPCSTR optional
-Fiddle::TYPE_INT, # CopyFlags : DWORD
Fiddle::TYPE_VOIDP, # MsgHandler : PSP_FILE_CALLBACK_A optional
Fiddle::TYPE_VOIDP, # Context : void* optional
Fiddle::TYPE_INTPTR_T, # DeviceInfoSet : HDEVINFO optional
Fiddle::TYPE_VOIDP, # DeviceInfoData : SP_DEVINFO_DATA* optional
],
Fiddle::TYPE_INT)#[link(name = "setupapi")]
extern "system" {
fn SetupInstallFromInfSectionA(
Owner: *mut core::ffi::c_void, // HWND optional
InfHandle: *mut (), // void*
SectionName: *const u8, // LPCSTR
Flags: u32, // DWORD
RelativeKeyRoot: *mut core::ffi::c_void, // HKEY optional
SourceRootPath: *const u8, // LPCSTR optional
CopyFlags: u32, // DWORD
MsgHandler: *const core::ffi::c_void, // PSP_FILE_CALLBACK_A optional
Context: *mut (), // void* optional
DeviceInfoSet: isize, // HDEVINFO optional
DeviceInfoData: *mut SP_DEVINFO_DATA // SP_DEVINFO_DATA* optional
) -> 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 SetupInstallFromInfSectionA(IntPtr Owner, IntPtr InfHandle, [MarshalAs(UnmanagedType.LPStr)] string SectionName, uint Flags, IntPtr RelativeKeyRoot, [MarshalAs(UnmanagedType.LPStr)] string SourceRootPath, uint CopyFlags, IntPtr MsgHandler, IntPtr Context, IntPtr DeviceInfoSet, IntPtr DeviceInfoData);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupInstallFromInfSectionA' -Namespace Win32 -PassThru
# $api::SetupInstallFromInfSectionA(Owner, InfHandle, SectionName, Flags, RelativeKeyRoot, SourceRootPath, CopyFlags, MsgHandler, Context, DeviceInfoSet, DeviceInfoData)#uselib "SETUPAPI.dll"
#func global SetupInstallFromInfSectionA "SetupInstallFromInfSectionA" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; SetupInstallFromInfSectionA Owner, InfHandle, SectionName, Flags, RelativeKeyRoot, SourceRootPath, CopyFlags, MsgHandler, Context, DeviceInfoSet, varptr(DeviceInfoData) ; 戻り値は stat
; Owner : HWND optional -> "sptr"
; InfHandle : void* -> "sptr"
; SectionName : LPCSTR -> "sptr"
; Flags : DWORD -> "sptr"
; RelativeKeyRoot : HKEY optional -> "sptr"
; SourceRootPath : LPCSTR optional -> "sptr"
; CopyFlags : DWORD -> "sptr"
; MsgHandler : PSP_FILE_CALLBACK_A optional -> "sptr"
; Context : void* optional -> "sptr"
; DeviceInfoSet : HDEVINFO optional -> "sptr"
; DeviceInfoData : SP_DEVINFO_DATA* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SETUPAPI.dll" #cfunc global SetupInstallFromInfSectionA "SetupInstallFromInfSectionA" sptr, sptr, str, int, sptr, str, int, sptr, sptr, sptr, var ; res = SetupInstallFromInfSectionA(Owner, InfHandle, SectionName, Flags, RelativeKeyRoot, SourceRootPath, CopyFlags, MsgHandler, Context, DeviceInfoSet, DeviceInfoData) ; Owner : HWND optional -> "sptr" ; InfHandle : void* -> "sptr" ; SectionName : LPCSTR -> "str" ; Flags : DWORD -> "int" ; RelativeKeyRoot : HKEY optional -> "sptr" ; SourceRootPath : LPCSTR optional -> "str" ; CopyFlags : DWORD -> "int" ; MsgHandler : PSP_FILE_CALLBACK_A optional -> "sptr" ; Context : void* optional -> "sptr" ; DeviceInfoSet : HDEVINFO optional -> "sptr" ; DeviceInfoData : SP_DEVINFO_DATA* optional -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SETUPAPI.dll" #cfunc global SetupInstallFromInfSectionA "SetupInstallFromInfSectionA" sptr, sptr, str, int, sptr, str, int, sptr, sptr, sptr, sptr ; res = SetupInstallFromInfSectionA(Owner, InfHandle, SectionName, Flags, RelativeKeyRoot, SourceRootPath, CopyFlags, MsgHandler, Context, DeviceInfoSet, varptr(DeviceInfoData)) ; Owner : HWND optional -> "sptr" ; InfHandle : void* -> "sptr" ; SectionName : LPCSTR -> "str" ; Flags : DWORD -> "int" ; RelativeKeyRoot : HKEY optional -> "sptr" ; SourceRootPath : LPCSTR optional -> "str" ; CopyFlags : DWORD -> "int" ; MsgHandler : PSP_FILE_CALLBACK_A optional -> "sptr" ; Context : void* optional -> "sptr" ; DeviceInfoSet : HDEVINFO optional -> "sptr" ; DeviceInfoData : SP_DEVINFO_DATA* optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL SetupInstallFromInfSectionA(HWND Owner, void* InfHandle, LPCSTR SectionName, DWORD Flags, HKEY RelativeKeyRoot, LPCSTR SourceRootPath, DWORD CopyFlags, PSP_FILE_CALLBACK_A MsgHandler, void* Context, HDEVINFO DeviceInfoSet, SP_DEVINFO_DATA* DeviceInfoData) #uselib "SETUPAPI.dll" #cfunc global SetupInstallFromInfSectionA "SetupInstallFromInfSectionA" intptr, intptr, str, int, intptr, str, int, intptr, intptr, intptr, var ; res = SetupInstallFromInfSectionA(Owner, InfHandle, SectionName, Flags, RelativeKeyRoot, SourceRootPath, CopyFlags, MsgHandler, Context, DeviceInfoSet, DeviceInfoData) ; Owner : HWND optional -> "intptr" ; InfHandle : void* -> "intptr" ; SectionName : LPCSTR -> "str" ; Flags : DWORD -> "int" ; RelativeKeyRoot : HKEY optional -> "intptr" ; SourceRootPath : LPCSTR optional -> "str" ; CopyFlags : DWORD -> "int" ; MsgHandler : PSP_FILE_CALLBACK_A optional -> "intptr" ; Context : void* optional -> "intptr" ; DeviceInfoSet : HDEVINFO optional -> "intptr" ; DeviceInfoData : SP_DEVINFO_DATA* optional -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL SetupInstallFromInfSectionA(HWND Owner, void* InfHandle, LPCSTR SectionName, DWORD Flags, HKEY RelativeKeyRoot, LPCSTR SourceRootPath, DWORD CopyFlags, PSP_FILE_CALLBACK_A MsgHandler, void* Context, HDEVINFO DeviceInfoSet, SP_DEVINFO_DATA* DeviceInfoData) #uselib "SETUPAPI.dll" #cfunc global SetupInstallFromInfSectionA "SetupInstallFromInfSectionA" intptr, intptr, str, int, intptr, str, int, intptr, intptr, intptr, intptr ; res = SetupInstallFromInfSectionA(Owner, InfHandle, SectionName, Flags, RelativeKeyRoot, SourceRootPath, CopyFlags, MsgHandler, Context, DeviceInfoSet, varptr(DeviceInfoData)) ; Owner : HWND optional -> "intptr" ; InfHandle : void* -> "intptr" ; SectionName : LPCSTR -> "str" ; Flags : DWORD -> "int" ; RelativeKeyRoot : HKEY optional -> "intptr" ; SourceRootPath : LPCSTR optional -> "str" ; CopyFlags : DWORD -> "int" ; MsgHandler : PSP_FILE_CALLBACK_A optional -> "intptr" ; Context : void* optional -> "intptr" ; DeviceInfoSet : HDEVINFO optional -> "intptr" ; DeviceInfoData : SP_DEVINFO_DATA* optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
procSetupInstallFromInfSectionA = setupapi.NewProc("SetupInstallFromInfSectionA")
)
// Owner (HWND optional), InfHandle (void*), SectionName (LPCSTR), Flags (DWORD), RelativeKeyRoot (HKEY optional), SourceRootPath (LPCSTR optional), CopyFlags (DWORD), MsgHandler (PSP_FILE_CALLBACK_A optional), Context (void* optional), DeviceInfoSet (HDEVINFO optional), DeviceInfoData (SP_DEVINFO_DATA* optional)
r1, _, err := procSetupInstallFromInfSectionA.Call(
uintptr(Owner),
uintptr(InfHandle),
uintptr(unsafe.Pointer(windows.BytePtrFromString(SectionName))),
uintptr(Flags),
uintptr(RelativeKeyRoot),
uintptr(unsafe.Pointer(windows.BytePtrFromString(SourceRootPath))),
uintptr(CopyFlags),
uintptr(MsgHandler),
uintptr(Context),
uintptr(DeviceInfoSet),
uintptr(DeviceInfoData),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetupInstallFromInfSectionA(
Owner: THandle; // HWND optional
InfHandle: Pointer; // void*
SectionName: PAnsiChar; // LPCSTR
Flags: DWORD; // DWORD
RelativeKeyRoot: THandle; // HKEY optional
SourceRootPath: PAnsiChar; // LPCSTR optional
CopyFlags: DWORD; // DWORD
MsgHandler: Pointer; // PSP_FILE_CALLBACK_A optional
Context: Pointer; // void* optional
DeviceInfoSet: NativeInt; // HDEVINFO optional
DeviceInfoData: Pointer // SP_DEVINFO_DATA* optional
): BOOL; stdcall;
external 'SETUPAPI.dll' name 'SetupInstallFromInfSectionA';result := DllCall("SETUPAPI\SetupInstallFromInfSectionA"
, "Ptr", Owner ; HWND optional
, "Ptr", InfHandle ; void*
, "AStr", SectionName ; LPCSTR
, "UInt", Flags ; DWORD
, "Ptr", RelativeKeyRoot ; HKEY optional
, "AStr", SourceRootPath ; LPCSTR optional
, "UInt", CopyFlags ; DWORD
, "Ptr", MsgHandler ; PSP_FILE_CALLBACK_A optional
, "Ptr", Context ; void* optional
, "Ptr", DeviceInfoSet ; HDEVINFO optional
, "Ptr", DeviceInfoData ; SP_DEVINFO_DATA* optional
, "Int") ; return: BOOL●SetupInstallFromInfSectionA(Owner, InfHandle, SectionName, Flags, RelativeKeyRoot, SourceRootPath, CopyFlags, MsgHandler, Context, DeviceInfoSet, DeviceInfoData) = DLL("SETUPAPI.dll", "bool SetupInstallFromInfSectionA(void*, void*, char*, dword, void*, char*, dword, void*, void*, int, void*)")
# 呼び出し: SetupInstallFromInfSectionA(Owner, InfHandle, SectionName, Flags, RelativeKeyRoot, SourceRootPath, CopyFlags, MsgHandler, Context, DeviceInfoSet, DeviceInfoData)
# Owner : HWND optional -> "void*"
# InfHandle : void* -> "void*"
# SectionName : LPCSTR -> "char*"
# Flags : DWORD -> "dword"
# RelativeKeyRoot : HKEY optional -> "void*"
# SourceRootPath : LPCSTR optional -> "char*"
# CopyFlags : DWORD -> "dword"
# MsgHandler : PSP_FILE_CALLBACK_A optional -> "void*"
# Context : void* optional -> "void*"
# DeviceInfoSet : HDEVINFO optional -> "int"
# DeviceInfoData : SP_DEVINFO_DATA* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。