ホーム › Devices.DeviceAndDriverInstallation › SetupBackupErrorA
SetupBackupErrorA
関数ファイルバックアップエラーを通知するダイアログを表示する(ANSI)。
シグネチャ
// SETUPAPI.dll (ANSI / -A)
#include <windows.h>
DWORD SetupBackupErrorA(
HWND hwndParent,
LPCSTR DialogTitle, // optional
LPCSTR SourceFile,
LPCSTR TargetFile, // optional
DWORD Win32ErrorCode,
DWORD Style
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hwndParent | HWND | in | エラーダイアログの親ウィンドウハンドル。NULL可。 |
| DialogTitle | LPCSTR | inoptional | ダイアログのタイトル文字列(ANSI)。NULLで既定値を使う。 |
| SourceFile | LPCSTR | in | バックアップ元ファイル名(ANSI)。 |
| TargetFile | LPCSTR | inoptional | バックアップ先ファイル名(ANSI)。NULL可。 |
| Win32ErrorCode | DWORD | in | 発生したWin32エラーコード。表示メッセージの決定に使う。 |
| Style | DWORD | in | ダイアログの表示動作を制御するスタイルフラグ。 |
戻り値の型: DWORD
各言語での呼び出し定義
// SETUPAPI.dll (ANSI / -A)
#include <windows.h>
DWORD SetupBackupErrorA(
HWND hwndParent,
LPCSTR DialogTitle, // optional
LPCSTR SourceFile,
LPCSTR TargetFile, // optional
DWORD Win32ErrorCode,
DWORD Style
);[DllImport("SETUPAPI.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern uint SetupBackupErrorA(
IntPtr hwndParent, // HWND
[MarshalAs(UnmanagedType.LPStr)] string DialogTitle, // LPCSTR optional
[MarshalAs(UnmanagedType.LPStr)] string SourceFile, // LPCSTR
[MarshalAs(UnmanagedType.LPStr)] string TargetFile, // LPCSTR optional
uint Win32ErrorCode, // DWORD
uint Style // DWORD
);<DllImport("SETUPAPI.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupBackupErrorA(
hwndParent As IntPtr, ' HWND
<MarshalAs(UnmanagedType.LPStr)> DialogTitle As String, ' LPCSTR optional
<MarshalAs(UnmanagedType.LPStr)> SourceFile As String, ' LPCSTR
<MarshalAs(UnmanagedType.LPStr)> TargetFile As String, ' LPCSTR optional
Win32ErrorCode As UInteger, ' DWORD
Style As UInteger ' DWORD
) As UInteger
End Function' hwndParent : HWND
' DialogTitle : LPCSTR optional
' SourceFile : LPCSTR
' TargetFile : LPCSTR optional
' Win32ErrorCode : DWORD
' Style : DWORD
Declare PtrSafe Function SetupBackupErrorA Lib "setupapi" ( _
ByVal hwndParent As LongPtr, _
ByVal DialogTitle As String, _
ByVal SourceFile As String, _
ByVal TargetFile As String, _
ByVal Win32ErrorCode As Long, _
ByVal Style As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetupBackupErrorA = ctypes.windll.setupapi.SetupBackupErrorA
SetupBackupErrorA.restype = wintypes.DWORD
SetupBackupErrorA.argtypes = [
wintypes.HANDLE, # hwndParent : HWND
wintypes.LPCSTR, # DialogTitle : LPCSTR optional
wintypes.LPCSTR, # SourceFile : LPCSTR
wintypes.LPCSTR, # TargetFile : LPCSTR 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')
SetupBackupErrorA = Fiddle::Function.new(
lib['SetupBackupErrorA'],
[
Fiddle::TYPE_VOIDP, # hwndParent : HWND
Fiddle::TYPE_VOIDP, # DialogTitle : LPCSTR optional
Fiddle::TYPE_VOIDP, # SourceFile : LPCSTR
Fiddle::TYPE_VOIDP, # TargetFile : LPCSTR optional
-Fiddle::TYPE_INT, # Win32ErrorCode : DWORD
-Fiddle::TYPE_INT, # Style : DWORD
],
-Fiddle::TYPE_INT)#[link(name = "setupapi")]
extern "system" {
fn SetupBackupErrorA(
hwndParent: *mut core::ffi::c_void, // HWND
DialogTitle: *const u8, // LPCSTR optional
SourceFile: *const u8, // LPCSTR
TargetFile: *const u8, // LPCSTR optional
Win32ErrorCode: u32, // DWORD
Style: u32 // DWORD
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SETUPAPI.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern uint SetupBackupErrorA(IntPtr hwndParent, [MarshalAs(UnmanagedType.LPStr)] string DialogTitle, [MarshalAs(UnmanagedType.LPStr)] string SourceFile, [MarshalAs(UnmanagedType.LPStr)] string TargetFile, uint Win32ErrorCode, uint Style);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupBackupErrorA' -Namespace Win32 -PassThru
# $api::SetupBackupErrorA(hwndParent, DialogTitle, SourceFile, TargetFile, Win32ErrorCode, Style)#uselib "SETUPAPI.dll"
#func global SetupBackupErrorA "SetupBackupErrorA" sptr, sptr, sptr, sptr, sptr, sptr
; SetupBackupErrorA hwndParent, DialogTitle, SourceFile, TargetFile, Win32ErrorCode, Style ; 戻り値は stat
; hwndParent : HWND -> "sptr"
; DialogTitle : LPCSTR optional -> "sptr"
; SourceFile : LPCSTR -> "sptr"
; TargetFile : LPCSTR optional -> "sptr"
; Win32ErrorCode : DWORD -> "sptr"
; Style : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "SETUPAPI.dll"
#cfunc global SetupBackupErrorA "SetupBackupErrorA" sptr, str, str, str, int, int
; res = SetupBackupErrorA(hwndParent, DialogTitle, SourceFile, TargetFile, Win32ErrorCode, Style)
; hwndParent : HWND -> "sptr"
; DialogTitle : LPCSTR optional -> "str"
; SourceFile : LPCSTR -> "str"
; TargetFile : LPCSTR optional -> "str"
; Win32ErrorCode : DWORD -> "int"
; Style : DWORD -> "int"; DWORD SetupBackupErrorA(HWND hwndParent, LPCSTR DialogTitle, LPCSTR SourceFile, LPCSTR TargetFile, DWORD Win32ErrorCode, DWORD Style)
#uselib "SETUPAPI.dll"
#cfunc global SetupBackupErrorA "SetupBackupErrorA" intptr, str, str, str, int, int
; res = SetupBackupErrorA(hwndParent, DialogTitle, SourceFile, TargetFile, Win32ErrorCode, Style)
; hwndParent : HWND -> "intptr"
; DialogTitle : LPCSTR optional -> "str"
; SourceFile : LPCSTR -> "str"
; TargetFile : LPCSTR optional -> "str"
; Win32ErrorCode : DWORD -> "int"
; Style : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
procSetupBackupErrorA = setupapi.NewProc("SetupBackupErrorA")
)
// hwndParent (HWND), DialogTitle (LPCSTR optional), SourceFile (LPCSTR), TargetFile (LPCSTR optional), Win32ErrorCode (DWORD), Style (DWORD)
r1, _, err := procSetupBackupErrorA.Call(
uintptr(hwndParent),
uintptr(unsafe.Pointer(windows.BytePtrFromString(DialogTitle))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(SourceFile))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(TargetFile))),
uintptr(Win32ErrorCode),
uintptr(Style),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction SetupBackupErrorA(
hwndParent: THandle; // HWND
DialogTitle: PAnsiChar; // LPCSTR optional
SourceFile: PAnsiChar; // LPCSTR
TargetFile: PAnsiChar; // LPCSTR optional
Win32ErrorCode: DWORD; // DWORD
Style: DWORD // DWORD
): DWORD; stdcall;
external 'SETUPAPI.dll' name 'SetupBackupErrorA';result := DllCall("SETUPAPI\SetupBackupErrorA"
, "Ptr", hwndParent ; HWND
, "AStr", DialogTitle ; LPCSTR optional
, "AStr", SourceFile ; LPCSTR
, "AStr", TargetFile ; LPCSTR optional
, "UInt", Win32ErrorCode ; DWORD
, "UInt", Style ; DWORD
, "UInt") ; return: DWORD●SetupBackupErrorA(hwndParent, DialogTitle, SourceFile, TargetFile, Win32ErrorCode, Style) = DLL("SETUPAPI.dll", "dword SetupBackupErrorA(void*, char*, char*, char*, dword, dword)")
# 呼び出し: SetupBackupErrorA(hwndParent, DialogTitle, SourceFile, TargetFile, Win32ErrorCode, Style)
# hwndParent : HWND -> "void*"
# DialogTitle : LPCSTR optional -> "char*"
# SourceFile : LPCSTR -> "char*"
# TargetFile : LPCSTR optional -> "char*"
# Win32ErrorCode : DWORD -> "dword"
# Style : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。