ホーム › Devices.DeviceAndDriverInstallation › SetupCopyErrorW
SetupCopyErrorW
関数ファイルコピーエラーを通知するダイアログを表示する(Unicode)。
シグネチャ
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
DWORD SetupCopyErrorW(
HWND hwndParent,
LPCWSTR DialogTitle, // optional
LPCWSTR DiskName, // optional
LPCWSTR PathToSource,
LPCWSTR SourceFile,
LPCWSTR TargetPathFile, // optional
DWORD Win32ErrorCode,
DWORD Style,
LPWSTR PathBuffer, // optional
DWORD PathBufferSize,
DWORD* PathRequiredSize // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hwndParent | HWND | in |
| DialogTitle | LPCWSTR | inoptional |
| DiskName | LPCWSTR | inoptional |
| PathToSource | LPCWSTR | in |
| SourceFile | LPCWSTR | in |
| TargetPathFile | LPCWSTR | inoptional |
| Win32ErrorCode | DWORD | in |
| Style | DWORD | in |
| PathBuffer | LPWSTR | outoptional |
| PathBufferSize | DWORD | in |
| PathRequiredSize | DWORD* | outoptional |
戻り値の型: DWORD
各言語での呼び出し定義
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
DWORD SetupCopyErrorW(
HWND hwndParent,
LPCWSTR DialogTitle, // optional
LPCWSTR DiskName, // optional
LPCWSTR PathToSource,
LPCWSTR SourceFile,
LPCWSTR TargetPathFile, // optional
DWORD Win32ErrorCode,
DWORD Style,
LPWSTR PathBuffer, // optional
DWORD PathBufferSize,
DWORD* PathRequiredSize // optional
);[DllImport("SETUPAPI.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern uint SetupCopyErrorW(
IntPtr hwndParent, // HWND
[MarshalAs(UnmanagedType.LPWStr)] string DialogTitle, // LPCWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string DiskName, // LPCWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string PathToSource, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string SourceFile, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string TargetPathFile, // LPCWSTR optional
uint Win32ErrorCode, // DWORD
uint Style, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder PathBuffer, // LPWSTR optional, out
uint PathBufferSize, // DWORD
IntPtr PathRequiredSize // DWORD* optional, out
);<DllImport("SETUPAPI.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupCopyErrorW(
hwndParent As IntPtr, ' HWND
<MarshalAs(UnmanagedType.LPWStr)> DialogTitle As String, ' LPCWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> DiskName As String, ' LPCWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> PathToSource As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> SourceFile As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> TargetPathFile As String, ' LPCWSTR optional
Win32ErrorCode As UInteger, ' DWORD
Style As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> PathBuffer As System.Text.StringBuilder, ' LPWSTR optional, out
PathBufferSize As UInteger, ' DWORD
PathRequiredSize As IntPtr ' DWORD* optional, out
) As UInteger
End Function' hwndParent : HWND
' DialogTitle : LPCWSTR optional
' DiskName : LPCWSTR optional
' PathToSource : LPCWSTR
' SourceFile : LPCWSTR
' TargetPathFile : LPCWSTR optional
' Win32ErrorCode : DWORD
' Style : DWORD
' PathBuffer : LPWSTR optional, out
' PathBufferSize : DWORD
' PathRequiredSize : DWORD* optional, out
Declare PtrSafe Function SetupCopyErrorW Lib "setupapi" ( _
ByVal hwndParent As LongPtr, _
ByVal DialogTitle As LongPtr, _
ByVal DiskName As LongPtr, _
ByVal PathToSource As LongPtr, _
ByVal SourceFile As LongPtr, _
ByVal TargetPathFile As LongPtr, _
ByVal Win32ErrorCode As Long, _
ByVal Style As Long, _
ByVal PathBuffer As LongPtr, _
ByVal PathBufferSize As Long, _
ByVal PathRequiredSize As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetupCopyErrorW = ctypes.windll.setupapi.SetupCopyErrorW
SetupCopyErrorW.restype = wintypes.DWORD
SetupCopyErrorW.argtypes = [
wintypes.HANDLE, # hwndParent : HWND
wintypes.LPCWSTR, # DialogTitle : LPCWSTR optional
wintypes.LPCWSTR, # DiskName : LPCWSTR optional
wintypes.LPCWSTR, # PathToSource : LPCWSTR
wintypes.LPCWSTR, # SourceFile : LPCWSTR
wintypes.LPCWSTR, # TargetPathFile : LPCWSTR optional
wintypes.DWORD, # Win32ErrorCode : DWORD
wintypes.DWORD, # Style : DWORD
wintypes.LPWSTR, # PathBuffer : LPWSTR 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')
SetupCopyErrorW = Fiddle::Function.new(
lib['SetupCopyErrorW'],
[
Fiddle::TYPE_VOIDP, # hwndParent : HWND
Fiddle::TYPE_VOIDP, # DialogTitle : LPCWSTR optional
Fiddle::TYPE_VOIDP, # DiskName : LPCWSTR optional
Fiddle::TYPE_VOIDP, # PathToSource : LPCWSTR
Fiddle::TYPE_VOIDP, # SourceFile : LPCWSTR
Fiddle::TYPE_VOIDP, # TargetPathFile : LPCWSTR optional
-Fiddle::TYPE_INT, # Win32ErrorCode : DWORD
-Fiddle::TYPE_INT, # Style : DWORD
Fiddle::TYPE_VOIDP, # PathBuffer : LPWSTR optional, out
-Fiddle::TYPE_INT, # PathBufferSize : DWORD
Fiddle::TYPE_VOIDP, # PathRequiredSize : DWORD* optional, out
],
-Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "setupapi")]
extern "system" {
fn SetupCopyErrorW(
hwndParent: *mut core::ffi::c_void, // HWND
DialogTitle: *const u16, // LPCWSTR optional
DiskName: *const u16, // LPCWSTR optional
PathToSource: *const u16, // LPCWSTR
SourceFile: *const u16, // LPCWSTR
TargetPathFile: *const u16, // LPCWSTR optional
Win32ErrorCode: u32, // DWORD
Style: u32, // DWORD
PathBuffer: *mut u16, // LPWSTR 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.Unicode, SetLastError = true)]
public static extern uint SetupCopyErrorW(IntPtr hwndParent, [MarshalAs(UnmanagedType.LPWStr)] string DialogTitle, [MarshalAs(UnmanagedType.LPWStr)] string DiskName, [MarshalAs(UnmanagedType.LPWStr)] string PathToSource, [MarshalAs(UnmanagedType.LPWStr)] string SourceFile, [MarshalAs(UnmanagedType.LPWStr)] string TargetPathFile, uint Win32ErrorCode, uint Style, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder PathBuffer, uint PathBufferSize, IntPtr PathRequiredSize);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupCopyErrorW' -Namespace Win32 -PassThru
# $api::SetupCopyErrorW(hwndParent, DialogTitle, DiskName, PathToSource, SourceFile, TargetPathFile, Win32ErrorCode, Style, PathBuffer, PathBufferSize, PathRequiredSize)#uselib "SETUPAPI.dll"
#func global SetupCopyErrorW "SetupCopyErrorW" wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr
; SetupCopyErrorW hwndParent, DialogTitle, DiskName, PathToSource, SourceFile, TargetPathFile, Win32ErrorCode, Style, varptr(PathBuffer), PathBufferSize, varptr(PathRequiredSize) ; 戻り値は stat
; hwndParent : HWND -> "wptr"
; DialogTitle : LPCWSTR optional -> "wptr"
; DiskName : LPCWSTR optional -> "wptr"
; PathToSource : LPCWSTR -> "wptr"
; SourceFile : LPCWSTR -> "wptr"
; TargetPathFile : LPCWSTR optional -> "wptr"
; Win32ErrorCode : DWORD -> "wptr"
; Style : DWORD -> "wptr"
; PathBuffer : LPWSTR optional, out -> "wptr"
; PathBufferSize : DWORD -> "wptr"
; PathRequiredSize : DWORD* optional, out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SETUPAPI.dll" #cfunc global SetupCopyErrorW "SetupCopyErrorW" sptr, wstr, wstr, wstr, wstr, wstr, int, int, var, int, var ; res = SetupCopyErrorW(hwndParent, DialogTitle, DiskName, PathToSource, SourceFile, TargetPathFile, Win32ErrorCode, Style, PathBuffer, PathBufferSize, PathRequiredSize) ; hwndParent : HWND -> "sptr" ; DialogTitle : LPCWSTR optional -> "wstr" ; DiskName : LPCWSTR optional -> "wstr" ; PathToSource : LPCWSTR -> "wstr" ; SourceFile : LPCWSTR -> "wstr" ; TargetPathFile : LPCWSTR optional -> "wstr" ; Win32ErrorCode : DWORD -> "int" ; Style : DWORD -> "int" ; PathBuffer : LPWSTR optional, out -> "var" ; PathBufferSize : DWORD -> "int" ; PathRequiredSize : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SETUPAPI.dll" #cfunc global SetupCopyErrorW "SetupCopyErrorW" sptr, wstr, wstr, wstr, wstr, wstr, int, int, sptr, int, sptr ; res = SetupCopyErrorW(hwndParent, DialogTitle, DiskName, PathToSource, SourceFile, TargetPathFile, Win32ErrorCode, Style, varptr(PathBuffer), PathBufferSize, varptr(PathRequiredSize)) ; hwndParent : HWND -> "sptr" ; DialogTitle : LPCWSTR optional -> "wstr" ; DiskName : LPCWSTR optional -> "wstr" ; PathToSource : LPCWSTR -> "wstr" ; SourceFile : LPCWSTR -> "wstr" ; TargetPathFile : LPCWSTR optional -> "wstr" ; Win32ErrorCode : DWORD -> "int" ; Style : DWORD -> "int" ; PathBuffer : LPWSTR optional, out -> "sptr" ; PathBufferSize : DWORD -> "int" ; PathRequiredSize : DWORD* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD SetupCopyErrorW(HWND hwndParent, LPCWSTR DialogTitle, LPCWSTR DiskName, LPCWSTR PathToSource, LPCWSTR SourceFile, LPCWSTR TargetPathFile, DWORD Win32ErrorCode, DWORD Style, LPWSTR PathBuffer, DWORD PathBufferSize, DWORD* PathRequiredSize) #uselib "SETUPAPI.dll" #cfunc global SetupCopyErrorW "SetupCopyErrorW" intptr, wstr, wstr, wstr, wstr, wstr, int, int, var, int, var ; res = SetupCopyErrorW(hwndParent, DialogTitle, DiskName, PathToSource, SourceFile, TargetPathFile, Win32ErrorCode, Style, PathBuffer, PathBufferSize, PathRequiredSize) ; hwndParent : HWND -> "intptr" ; DialogTitle : LPCWSTR optional -> "wstr" ; DiskName : LPCWSTR optional -> "wstr" ; PathToSource : LPCWSTR -> "wstr" ; SourceFile : LPCWSTR -> "wstr" ; TargetPathFile : LPCWSTR optional -> "wstr" ; Win32ErrorCode : DWORD -> "int" ; Style : DWORD -> "int" ; PathBuffer : LPWSTR optional, out -> "var" ; PathBufferSize : DWORD -> "int" ; PathRequiredSize : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD SetupCopyErrorW(HWND hwndParent, LPCWSTR DialogTitle, LPCWSTR DiskName, LPCWSTR PathToSource, LPCWSTR SourceFile, LPCWSTR TargetPathFile, DWORD Win32ErrorCode, DWORD Style, LPWSTR PathBuffer, DWORD PathBufferSize, DWORD* PathRequiredSize) #uselib "SETUPAPI.dll" #cfunc global SetupCopyErrorW "SetupCopyErrorW" intptr, wstr, wstr, wstr, wstr, wstr, int, int, intptr, int, intptr ; res = SetupCopyErrorW(hwndParent, DialogTitle, DiskName, PathToSource, SourceFile, TargetPathFile, Win32ErrorCode, Style, varptr(PathBuffer), PathBufferSize, varptr(PathRequiredSize)) ; hwndParent : HWND -> "intptr" ; DialogTitle : LPCWSTR optional -> "wstr" ; DiskName : LPCWSTR optional -> "wstr" ; PathToSource : LPCWSTR -> "wstr" ; SourceFile : LPCWSTR -> "wstr" ; TargetPathFile : LPCWSTR optional -> "wstr" ; Win32ErrorCode : DWORD -> "int" ; Style : DWORD -> "int" ; PathBuffer : LPWSTR 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")
procSetupCopyErrorW = setupapi.NewProc("SetupCopyErrorW")
)
// hwndParent (HWND), DialogTitle (LPCWSTR optional), DiskName (LPCWSTR optional), PathToSource (LPCWSTR), SourceFile (LPCWSTR), TargetPathFile (LPCWSTR optional), Win32ErrorCode (DWORD), Style (DWORD), PathBuffer (LPWSTR optional, out), PathBufferSize (DWORD), PathRequiredSize (DWORD* optional, out)
r1, _, err := procSetupCopyErrorW.Call(
uintptr(hwndParent),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(DialogTitle))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(DiskName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(PathToSource))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(SourceFile))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(TargetPathFile))),
uintptr(Win32ErrorCode),
uintptr(Style),
uintptr(PathBuffer),
uintptr(PathBufferSize),
uintptr(PathRequiredSize),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction SetupCopyErrorW(
hwndParent: THandle; // HWND
DialogTitle: PWideChar; // LPCWSTR optional
DiskName: PWideChar; // LPCWSTR optional
PathToSource: PWideChar; // LPCWSTR
SourceFile: PWideChar; // LPCWSTR
TargetPathFile: PWideChar; // LPCWSTR optional
Win32ErrorCode: DWORD; // DWORD
Style: DWORD; // DWORD
PathBuffer: PWideChar; // LPWSTR optional, out
PathBufferSize: DWORD; // DWORD
PathRequiredSize: Pointer // DWORD* optional, out
): DWORD; stdcall;
external 'SETUPAPI.dll' name 'SetupCopyErrorW';result := DllCall("SETUPAPI\SetupCopyErrorW"
, "Ptr", hwndParent ; HWND
, "WStr", DialogTitle ; LPCWSTR optional
, "WStr", DiskName ; LPCWSTR optional
, "WStr", PathToSource ; LPCWSTR
, "WStr", SourceFile ; LPCWSTR
, "WStr", TargetPathFile ; LPCWSTR optional
, "UInt", Win32ErrorCode ; DWORD
, "UInt", Style ; DWORD
, "Ptr", PathBuffer ; LPWSTR optional, out
, "UInt", PathBufferSize ; DWORD
, "Ptr", PathRequiredSize ; DWORD* optional, out
, "UInt") ; return: DWORD●SetupCopyErrorW(hwndParent, DialogTitle, DiskName, PathToSource, SourceFile, TargetPathFile, Win32ErrorCode, Style, PathBuffer, PathBufferSize, PathRequiredSize) = DLL("SETUPAPI.dll", "dword SetupCopyErrorW(void*, char*, char*, char*, char*, char*, dword, dword, char*, dword, void*)")
# 呼び出し: SetupCopyErrorW(hwndParent, DialogTitle, DiskName, PathToSource, SourceFile, TargetPathFile, Win32ErrorCode, Style, PathBuffer, PathBufferSize, PathRequiredSize)
# hwndParent : HWND -> "void*"
# DialogTitle : LPCWSTR optional -> "char*"
# DiskName : LPCWSTR optional -> "char*"
# PathToSource : LPCWSTR -> "char*"
# SourceFile : LPCWSTR -> "char*"
# TargetPathFile : LPCWSTR optional -> "char*"
# Win32ErrorCode : DWORD -> "dword"
# Style : DWORD -> "dword"
# PathBuffer : LPWSTR optional, out -> "char*"
# PathBufferSize : DWORD -> "dword"
# PathRequiredSize : DWORD* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。