Win32 API 日本語リファレンス
ホームDevices.DeviceAndDriverInstallation › SetupBackupErrorW

SetupBackupErrorW

関数
ファイルバックアップエラーを通知するダイアログを表示する(Unicode)。
DLLSETUPAPI.dll文字セットUnicode (-W)呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

// SETUPAPI.dll  (Unicode / -W)
#include <windows.h>

DWORD SetupBackupErrorW(
    HWND hwndParent,
    LPCWSTR DialogTitle,   // optional
    LPCWSTR SourceFile,
    LPCWSTR TargetFile,   // optional
    DWORD Win32ErrorCode,
    DWORD Style
);

パラメーター

名前方向
hwndParentHWNDin
DialogTitleLPCWSTRinoptional
SourceFileLPCWSTRin
TargetFileLPCWSTRinoptional
Win32ErrorCodeDWORDin
StyleDWORDin

戻り値の型: DWORD

各言語での呼び出し定義

// SETUPAPI.dll  (Unicode / -W)
#include <windows.h>

DWORD SetupBackupErrorW(
    HWND hwndParent,
    LPCWSTR DialogTitle,   // optional
    LPCWSTR SourceFile,
    LPCWSTR TargetFile,   // optional
    DWORD Win32ErrorCode,
    DWORD Style
);
[DllImport("SETUPAPI.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern uint SetupBackupErrorW(
    IntPtr hwndParent,   // HWND
    [MarshalAs(UnmanagedType.LPWStr)] string DialogTitle,   // LPCWSTR optional
    [MarshalAs(UnmanagedType.LPWStr)] string SourceFile,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string TargetFile,   // LPCWSTR optional
    uint Win32ErrorCode,   // DWORD
    uint Style   // DWORD
);
<DllImport("SETUPAPI.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupBackupErrorW(
    hwndParent As IntPtr,   ' HWND
    <MarshalAs(UnmanagedType.LPWStr)> DialogTitle As String,   ' LPCWSTR optional
    <MarshalAs(UnmanagedType.LPWStr)> SourceFile As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> TargetFile As String,   ' LPCWSTR optional
    Win32ErrorCode As UInteger,   ' DWORD
    Style As UInteger   ' DWORD
) As UInteger
End Function
' hwndParent : HWND
' DialogTitle : LPCWSTR optional
' SourceFile : LPCWSTR
' TargetFile : LPCWSTR optional
' Win32ErrorCode : DWORD
' Style : DWORD
Declare PtrSafe Function SetupBackupErrorW Lib "setupapi" ( _
    ByVal hwndParent As LongPtr, _
    ByVal DialogTitle As LongPtr, _
    ByVal SourceFile As LongPtr, _
    ByVal TargetFile As LongPtr, _
    ByVal Win32ErrorCode As Long, _
    ByVal Style As Long) 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

SetupBackupErrorW = ctypes.windll.setupapi.SetupBackupErrorW
SetupBackupErrorW.restype = wintypes.DWORD
SetupBackupErrorW.argtypes = [
    wintypes.HANDLE,  # hwndParent : HWND
    wintypes.LPCWSTR,  # DialogTitle : LPCWSTR optional
    wintypes.LPCWSTR,  # SourceFile : LPCWSTR
    wintypes.LPCWSTR,  # TargetFile : LPCWSTR optional
    wintypes.DWORD,  # Win32ErrorCode : DWORD
    wintypes.DWORD,  # Style : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SETUPAPI.dll')
SetupBackupErrorW = Fiddle::Function.new(
  lib['SetupBackupErrorW'],
  [
    Fiddle::TYPE_VOIDP,  # hwndParent : HWND
    Fiddle::TYPE_VOIDP,  # DialogTitle : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # SourceFile : LPCWSTR
    Fiddle::TYPE_VOIDP,  # TargetFile : LPCWSTR optional
    -Fiddle::TYPE_INT,  # Win32ErrorCode : DWORD
    -Fiddle::TYPE_INT,  # Style : DWORD
  ],
  -Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "setupapi")]
extern "system" {
    fn SetupBackupErrorW(
        hwndParent: *mut core::ffi::c_void,  // HWND
        DialogTitle: *const u16,  // LPCWSTR optional
        SourceFile: *const u16,  // LPCWSTR
        TargetFile: *const u16,  // LPCWSTR optional
        Win32ErrorCode: u32,  // DWORD
        Style: u32  // DWORD
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("SETUPAPI.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern uint SetupBackupErrorW(IntPtr hwndParent, [MarshalAs(UnmanagedType.LPWStr)] string DialogTitle, [MarshalAs(UnmanagedType.LPWStr)] string SourceFile, [MarshalAs(UnmanagedType.LPWStr)] string TargetFile, uint Win32ErrorCode, uint Style);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupBackupErrorW' -Namespace Win32 -PassThru
# $api::SetupBackupErrorW(hwndParent, DialogTitle, SourceFile, TargetFile, Win32ErrorCode, Style)
#uselib "SETUPAPI.dll"
#func global SetupBackupErrorW "SetupBackupErrorW" wptr, wptr, wptr, wptr, wptr, wptr
; SetupBackupErrorW hwndParent, DialogTitle, SourceFile, TargetFile, Win32ErrorCode, Style   ; 戻り値は stat
; hwndParent : HWND -> "wptr"
; DialogTitle : LPCWSTR optional -> "wptr"
; SourceFile : LPCWSTR -> "wptr"
; TargetFile : LPCWSTR optional -> "wptr"
; Win32ErrorCode : DWORD -> "wptr"
; Style : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SETUPAPI.dll"
#cfunc global SetupBackupErrorW "SetupBackupErrorW" sptr, wstr, wstr, wstr, int, int
; res = SetupBackupErrorW(hwndParent, DialogTitle, SourceFile, TargetFile, Win32ErrorCode, Style)
; hwndParent : HWND -> "sptr"
; DialogTitle : LPCWSTR optional -> "wstr"
; SourceFile : LPCWSTR -> "wstr"
; TargetFile : LPCWSTR optional -> "wstr"
; Win32ErrorCode : DWORD -> "int"
; Style : DWORD -> "int"
; DWORD SetupBackupErrorW(HWND hwndParent, LPCWSTR DialogTitle, LPCWSTR SourceFile, LPCWSTR TargetFile, DWORD Win32ErrorCode, DWORD Style)
#uselib "SETUPAPI.dll"
#cfunc global SetupBackupErrorW "SetupBackupErrorW" intptr, wstr, wstr, wstr, int, int
; res = SetupBackupErrorW(hwndParent, DialogTitle, SourceFile, TargetFile, Win32ErrorCode, Style)
; hwndParent : HWND -> "intptr"
; DialogTitle : LPCWSTR optional -> "wstr"
; SourceFile : LPCWSTR -> "wstr"
; TargetFile : LPCWSTR optional -> "wstr"
; Win32ErrorCode : DWORD -> "int"
; Style : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
	procSetupBackupErrorW = setupapi.NewProc("SetupBackupErrorW")
)

// hwndParent (HWND), DialogTitle (LPCWSTR optional), SourceFile (LPCWSTR), TargetFile (LPCWSTR optional), Win32ErrorCode (DWORD), Style (DWORD)
r1, _, err := procSetupBackupErrorW.Call(
	uintptr(hwndParent),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(DialogTitle))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(SourceFile))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(TargetFile))),
	uintptr(Win32ErrorCode),
	uintptr(Style),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function SetupBackupErrorW(
  hwndParent: THandle;   // HWND
  DialogTitle: PWideChar;   // LPCWSTR optional
  SourceFile: PWideChar;   // LPCWSTR
  TargetFile: PWideChar;   // LPCWSTR optional
  Win32ErrorCode: DWORD;   // DWORD
  Style: DWORD   // DWORD
): DWORD; stdcall;
  external 'SETUPAPI.dll' name 'SetupBackupErrorW';
result := DllCall("SETUPAPI\SetupBackupErrorW"
    , "Ptr", hwndParent   ; HWND
    , "WStr", DialogTitle   ; LPCWSTR optional
    , "WStr", SourceFile   ; LPCWSTR
    , "WStr", TargetFile   ; LPCWSTR optional
    , "UInt", Win32ErrorCode   ; DWORD
    , "UInt", Style   ; DWORD
    , "UInt")   ; return: DWORD
●SetupBackupErrorW(hwndParent, DialogTitle, SourceFile, TargetFile, Win32ErrorCode, Style) = DLL("SETUPAPI.dll", "dword SetupBackupErrorW(void*, char*, char*, char*, dword, dword)")
# 呼び出し: SetupBackupErrorW(hwndParent, DialogTitle, SourceFile, TargetFile, Win32ErrorCode, Style)
# hwndParent : HWND -> "void*"
# DialogTitle : LPCWSTR optional -> "char*"
# SourceFile : LPCWSTR -> "char*"
# TargetFile : LPCWSTR optional -> "char*"
# Win32ErrorCode : DWORD -> "dword"
# Style : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。