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