ホーム › Devices.DeviceAndDriverInstallation › SetupCopyErrorA
SetupCopyErrorA
関数ファイルコピーエラーを通知するダイアログを表示する(ANSI)。
シグネチャ
// SETUPAPI.dll (ANSI / -A)
#include <windows.h>
DWORD SetupCopyErrorA(
HWND hwndParent,
LPCSTR DialogTitle, // optional
LPCSTR DiskName, // optional
LPCSTR PathToSource,
LPCSTR SourceFile,
LPCSTR TargetPathFile, // optional
DWORD Win32ErrorCode,
DWORD Style,
LPSTR PathBuffer, // optional
DWORD PathBufferSize,
DWORD* PathRequiredSize // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hwndParent | HWND | in |
| DialogTitle | LPCSTR | inoptional |
| DiskName | LPCSTR | inoptional |
| PathToSource | LPCSTR | in |
| SourceFile | LPCSTR | in |
| TargetPathFile | LPCSTR | inoptional |
| Win32ErrorCode | DWORD | in |
| Style | DWORD | in |
| PathBuffer | LPSTR | outoptional |
| PathBufferSize | DWORD | in |
| PathRequiredSize | DWORD* | outoptional |
戻り値の型: DWORD
各言語での呼び出し定義
// SETUPAPI.dll (ANSI / -A)
#include <windows.h>
DWORD SetupCopyErrorA(
HWND hwndParent,
LPCSTR DialogTitle, // optional
LPCSTR DiskName, // optional
LPCSTR PathToSource,
LPCSTR SourceFile,
LPCSTR TargetPathFile, // optional
DWORD Win32ErrorCode,
DWORD Style,
LPSTR PathBuffer, // optional
DWORD PathBufferSize,
DWORD* PathRequiredSize // optional
);[DllImport("SETUPAPI.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern uint SetupCopyErrorA(
IntPtr hwndParent, // HWND
[MarshalAs(UnmanagedType.LPStr)] string DialogTitle, // LPCSTR optional
[MarshalAs(UnmanagedType.LPStr)] string DiskName, // LPCSTR optional
[MarshalAs(UnmanagedType.LPStr)] string PathToSource, // LPCSTR
[MarshalAs(UnmanagedType.LPStr)] string SourceFile, // LPCSTR
[MarshalAs(UnmanagedType.LPStr)] string TargetPathFile, // LPCSTR optional
uint Win32ErrorCode, // DWORD
uint Style, // DWORD
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder PathBuffer, // LPSTR optional, out
uint PathBufferSize, // DWORD
IntPtr PathRequiredSize // DWORD* optional, out
);<DllImport("SETUPAPI.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupCopyErrorA(
hwndParent As IntPtr, ' HWND
<MarshalAs(UnmanagedType.LPStr)> DialogTitle As String, ' LPCSTR optional
<MarshalAs(UnmanagedType.LPStr)> DiskName As String, ' LPCSTR optional
<MarshalAs(UnmanagedType.LPStr)> PathToSource As String, ' LPCSTR
<MarshalAs(UnmanagedType.LPStr)> SourceFile As String, ' LPCSTR
<MarshalAs(UnmanagedType.LPStr)> TargetPathFile As String, ' LPCSTR optional
Win32ErrorCode As UInteger, ' DWORD
Style As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPStr)> PathBuffer As System.Text.StringBuilder, ' LPSTR optional, out
PathBufferSize As UInteger, ' DWORD
PathRequiredSize As IntPtr ' DWORD* optional, out
) As UInteger
End Function' hwndParent : HWND
' DialogTitle : LPCSTR optional
' DiskName : LPCSTR optional
' PathToSource : LPCSTR
' SourceFile : LPCSTR
' TargetPathFile : LPCSTR optional
' Win32ErrorCode : DWORD
' Style : DWORD
' PathBuffer : LPSTR optional, out
' PathBufferSize : DWORD
' PathRequiredSize : DWORD* optional, out
Declare PtrSafe Function SetupCopyErrorA Lib "setupapi" ( _
ByVal hwndParent As LongPtr, _
ByVal DialogTitle As String, _
ByVal DiskName As String, _
ByVal PathToSource As String, _
ByVal SourceFile As String, _
ByVal TargetPathFile As String, _
ByVal Win32ErrorCode As Long, _
ByVal Style As Long, _
ByVal PathBuffer As String, _
ByVal PathBufferSize As Long, _
ByVal PathRequiredSize As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetupCopyErrorA = ctypes.windll.setupapi.SetupCopyErrorA
SetupCopyErrorA.restype = wintypes.DWORD
SetupCopyErrorA.argtypes = [
wintypes.HANDLE, # hwndParent : HWND
wintypes.LPCSTR, # DialogTitle : LPCSTR optional
wintypes.LPCSTR, # DiskName : LPCSTR optional
wintypes.LPCSTR, # PathToSource : LPCSTR
wintypes.LPCSTR, # SourceFile : LPCSTR
wintypes.LPCSTR, # TargetPathFile : LPCSTR optional
wintypes.DWORD, # Win32ErrorCode : DWORD
wintypes.DWORD, # Style : DWORD
wintypes.LPSTR, # PathBuffer : LPSTR optional, out
wintypes.DWORD, # PathBufferSize : DWORD
ctypes.POINTER(wintypes.DWORD), # PathRequiredSize : DWORD* optional, out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SETUPAPI.dll')
SetupCopyErrorA = Fiddle::Function.new(
lib['SetupCopyErrorA'],
[
Fiddle::TYPE_VOIDP, # hwndParent : HWND
Fiddle::TYPE_VOIDP, # DialogTitle : LPCSTR optional
Fiddle::TYPE_VOIDP, # DiskName : LPCSTR optional
Fiddle::TYPE_VOIDP, # PathToSource : LPCSTR
Fiddle::TYPE_VOIDP, # SourceFile : LPCSTR
Fiddle::TYPE_VOIDP, # TargetPathFile : LPCSTR optional
-Fiddle::TYPE_INT, # Win32ErrorCode : DWORD
-Fiddle::TYPE_INT, # Style : DWORD
Fiddle::TYPE_VOIDP, # PathBuffer : LPSTR optional, out
-Fiddle::TYPE_INT, # PathBufferSize : DWORD
Fiddle::TYPE_VOIDP, # PathRequiredSize : DWORD* optional, out
],
-Fiddle::TYPE_INT)#[link(name = "setupapi")]
extern "system" {
fn SetupCopyErrorA(
hwndParent: *mut core::ffi::c_void, // HWND
DialogTitle: *const u8, // LPCSTR optional
DiskName: *const u8, // LPCSTR optional
PathToSource: *const u8, // LPCSTR
SourceFile: *const u8, // LPCSTR
TargetPathFile: *const u8, // LPCSTR optional
Win32ErrorCode: u32, // DWORD
Style: u32, // DWORD
PathBuffer: *mut u8, // LPSTR optional, out
PathBufferSize: u32, // DWORD
PathRequiredSize: *mut u32 // DWORD* optional, out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SETUPAPI.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern uint SetupCopyErrorA(IntPtr hwndParent, [MarshalAs(UnmanagedType.LPStr)] string DialogTitle, [MarshalAs(UnmanagedType.LPStr)] string DiskName, [MarshalAs(UnmanagedType.LPStr)] string PathToSource, [MarshalAs(UnmanagedType.LPStr)] string SourceFile, [MarshalAs(UnmanagedType.LPStr)] string TargetPathFile, uint Win32ErrorCode, uint Style, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder PathBuffer, uint PathBufferSize, IntPtr PathRequiredSize);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupCopyErrorA' -Namespace Win32 -PassThru
# $api::SetupCopyErrorA(hwndParent, DialogTitle, DiskName, PathToSource, SourceFile, TargetPathFile, Win32ErrorCode, Style, PathBuffer, PathBufferSize, PathRequiredSize)#uselib "SETUPAPI.dll"
#func global SetupCopyErrorA "SetupCopyErrorA" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; SetupCopyErrorA hwndParent, DialogTitle, DiskName, PathToSource, SourceFile, TargetPathFile, Win32ErrorCode, Style, varptr(PathBuffer), PathBufferSize, varptr(PathRequiredSize) ; 戻り値は stat
; hwndParent : HWND -> "sptr"
; DialogTitle : LPCSTR optional -> "sptr"
; DiskName : LPCSTR optional -> "sptr"
; PathToSource : LPCSTR -> "sptr"
; SourceFile : LPCSTR -> "sptr"
; TargetPathFile : LPCSTR optional -> "sptr"
; Win32ErrorCode : DWORD -> "sptr"
; Style : DWORD -> "sptr"
; PathBuffer : LPSTR optional, out -> "sptr"
; PathBufferSize : DWORD -> "sptr"
; PathRequiredSize : DWORD* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SETUPAPI.dll" #cfunc global SetupCopyErrorA "SetupCopyErrorA" sptr, str, str, str, str, str, int, int, var, int, var ; res = SetupCopyErrorA(hwndParent, DialogTitle, DiskName, PathToSource, SourceFile, TargetPathFile, Win32ErrorCode, Style, PathBuffer, PathBufferSize, PathRequiredSize) ; hwndParent : HWND -> "sptr" ; DialogTitle : LPCSTR optional -> "str" ; DiskName : LPCSTR optional -> "str" ; PathToSource : LPCSTR -> "str" ; SourceFile : LPCSTR -> "str" ; TargetPathFile : LPCSTR optional -> "str" ; Win32ErrorCode : DWORD -> "int" ; Style : DWORD -> "int" ; PathBuffer : LPSTR optional, out -> "var" ; PathBufferSize : DWORD -> "int" ; PathRequiredSize : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SETUPAPI.dll" #cfunc global SetupCopyErrorA "SetupCopyErrorA" sptr, str, str, str, str, str, int, int, sptr, int, sptr ; res = SetupCopyErrorA(hwndParent, DialogTitle, DiskName, PathToSource, SourceFile, TargetPathFile, Win32ErrorCode, Style, varptr(PathBuffer), PathBufferSize, varptr(PathRequiredSize)) ; hwndParent : HWND -> "sptr" ; DialogTitle : LPCSTR optional -> "str" ; DiskName : LPCSTR optional -> "str" ; PathToSource : LPCSTR -> "str" ; SourceFile : LPCSTR -> "str" ; TargetPathFile : LPCSTR optional -> "str" ; Win32ErrorCode : DWORD -> "int" ; Style : DWORD -> "int" ; PathBuffer : LPSTR optional, out -> "sptr" ; PathBufferSize : DWORD -> "int" ; PathRequiredSize : DWORD* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD SetupCopyErrorA(HWND hwndParent, LPCSTR DialogTitle, LPCSTR DiskName, LPCSTR PathToSource, LPCSTR SourceFile, LPCSTR TargetPathFile, DWORD Win32ErrorCode, DWORD Style, LPSTR PathBuffer, DWORD PathBufferSize, DWORD* PathRequiredSize) #uselib "SETUPAPI.dll" #cfunc global SetupCopyErrorA "SetupCopyErrorA" intptr, str, str, str, str, str, int, int, var, int, var ; res = SetupCopyErrorA(hwndParent, DialogTitle, DiskName, PathToSource, SourceFile, TargetPathFile, Win32ErrorCode, Style, PathBuffer, PathBufferSize, PathRequiredSize) ; hwndParent : HWND -> "intptr" ; DialogTitle : LPCSTR optional -> "str" ; DiskName : LPCSTR optional -> "str" ; PathToSource : LPCSTR -> "str" ; SourceFile : LPCSTR -> "str" ; TargetPathFile : LPCSTR optional -> "str" ; Win32ErrorCode : DWORD -> "int" ; Style : DWORD -> "int" ; PathBuffer : LPSTR optional, out -> "var" ; PathBufferSize : DWORD -> "int" ; PathRequiredSize : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD SetupCopyErrorA(HWND hwndParent, LPCSTR DialogTitle, LPCSTR DiskName, LPCSTR PathToSource, LPCSTR SourceFile, LPCSTR TargetPathFile, DWORD Win32ErrorCode, DWORD Style, LPSTR PathBuffer, DWORD PathBufferSize, DWORD* PathRequiredSize) #uselib "SETUPAPI.dll" #cfunc global SetupCopyErrorA "SetupCopyErrorA" intptr, str, str, str, str, str, int, int, intptr, int, intptr ; res = SetupCopyErrorA(hwndParent, DialogTitle, DiskName, PathToSource, SourceFile, TargetPathFile, Win32ErrorCode, Style, varptr(PathBuffer), PathBufferSize, varptr(PathRequiredSize)) ; hwndParent : HWND -> "intptr" ; DialogTitle : LPCSTR optional -> "str" ; DiskName : LPCSTR optional -> "str" ; PathToSource : LPCSTR -> "str" ; SourceFile : LPCSTR -> "str" ; TargetPathFile : LPCSTR optional -> "str" ; Win32ErrorCode : DWORD -> "int" ; Style : DWORD -> "int" ; PathBuffer : LPSTR optional, out -> "intptr" ; PathBufferSize : DWORD -> "int" ; PathRequiredSize : DWORD* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
procSetupCopyErrorA = setupapi.NewProc("SetupCopyErrorA")
)
// hwndParent (HWND), DialogTitle (LPCSTR optional), DiskName (LPCSTR optional), PathToSource (LPCSTR), SourceFile (LPCSTR), TargetPathFile (LPCSTR optional), Win32ErrorCode (DWORD), Style (DWORD), PathBuffer (LPSTR optional, out), PathBufferSize (DWORD), PathRequiredSize (DWORD* optional, out)
r1, _, err := procSetupCopyErrorA.Call(
uintptr(hwndParent),
uintptr(unsafe.Pointer(windows.BytePtrFromString(DialogTitle))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(DiskName))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(PathToSource))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(SourceFile))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(TargetPathFile))),
uintptr(Win32ErrorCode),
uintptr(Style),
uintptr(PathBuffer),
uintptr(PathBufferSize),
uintptr(PathRequiredSize),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction SetupCopyErrorA(
hwndParent: THandle; // HWND
DialogTitle: PAnsiChar; // LPCSTR optional
DiskName: PAnsiChar; // LPCSTR optional
PathToSource: PAnsiChar; // LPCSTR
SourceFile: PAnsiChar; // LPCSTR
TargetPathFile: PAnsiChar; // LPCSTR optional
Win32ErrorCode: DWORD; // DWORD
Style: DWORD; // DWORD
PathBuffer: PAnsiChar; // LPSTR optional, out
PathBufferSize: DWORD; // DWORD
PathRequiredSize: Pointer // DWORD* optional, out
): DWORD; stdcall;
external 'SETUPAPI.dll' name 'SetupCopyErrorA';result := DllCall("SETUPAPI\SetupCopyErrorA"
, "Ptr", hwndParent ; HWND
, "AStr", DialogTitle ; LPCSTR optional
, "AStr", DiskName ; LPCSTR optional
, "AStr", PathToSource ; LPCSTR
, "AStr", SourceFile ; LPCSTR
, "AStr", TargetPathFile ; LPCSTR optional
, "UInt", Win32ErrorCode ; DWORD
, "UInt", Style ; DWORD
, "Ptr", PathBuffer ; LPSTR optional, out
, "UInt", PathBufferSize ; DWORD
, "Ptr", PathRequiredSize ; DWORD* optional, out
, "UInt") ; return: DWORD●SetupCopyErrorA(hwndParent, DialogTitle, DiskName, PathToSource, SourceFile, TargetPathFile, Win32ErrorCode, Style, PathBuffer, PathBufferSize, PathRequiredSize) = DLL("SETUPAPI.dll", "dword SetupCopyErrorA(void*, char*, char*, char*, char*, char*, dword, dword, char*, dword, void*)")
# 呼び出し: SetupCopyErrorA(hwndParent, DialogTitle, DiskName, PathToSource, SourceFile, TargetPathFile, Win32ErrorCode, Style, PathBuffer, PathBufferSize, PathRequiredSize)
# hwndParent : HWND -> "void*"
# DialogTitle : LPCSTR optional -> "char*"
# DiskName : LPCSTR optional -> "char*"
# PathToSource : LPCSTR -> "char*"
# SourceFile : LPCSTR -> "char*"
# TargetPathFile : LPCSTR optional -> "char*"
# Win32ErrorCode : DWORD -> "dword"
# Style : DWORD -> "dword"
# PathBuffer : LPSTR optional, out -> "char*"
# PathBufferSize : DWORD -> "dword"
# PathRequiredSize : DWORD* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。