ホーム › Devices.DeviceAndDriverInstallation › SetupRenameErrorW
SetupRenameErrorW
関数ファイル名変更エラーを通知するダイアログを表示する(Unicode)。
シグネチャ
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
DWORD SetupRenameErrorW(
HWND hwndParent,
LPCWSTR DialogTitle, // optional
LPCWSTR SourceFile,
LPCWSTR TargetFile,
DWORD Win32ErrorCode,
DWORD Style
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hwndParent | HWND | in |
| DialogTitle | LPCWSTR | inoptional |
| SourceFile | LPCWSTR | in |
| TargetFile | LPCWSTR | in |
| Win32ErrorCode | DWORD | in |
| Style | DWORD | in |
戻り値の型: DWORD
各言語での呼び出し定義
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
DWORD SetupRenameErrorW(
HWND hwndParent,
LPCWSTR DialogTitle, // optional
LPCWSTR SourceFile,
LPCWSTR TargetFile,
DWORD Win32ErrorCode,
DWORD Style
);[DllImport("SETUPAPI.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern uint SetupRenameErrorW(
IntPtr hwndParent, // HWND
[MarshalAs(UnmanagedType.LPWStr)] string DialogTitle, // LPCWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string SourceFile, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string TargetFile, // LPCWSTR
uint Win32ErrorCode, // DWORD
uint Style // DWORD
);<DllImport("SETUPAPI.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupRenameErrorW(
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
Win32ErrorCode As UInteger, ' DWORD
Style As UInteger ' DWORD
) As UInteger
End Function' hwndParent : HWND
' DialogTitle : LPCWSTR optional
' SourceFile : LPCWSTR
' TargetFile : LPCWSTR
' Win32ErrorCode : DWORD
' Style : DWORD
Declare PtrSafe Function SetupRenameErrorW 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
SetupRenameErrorW = ctypes.windll.setupapi.SetupRenameErrorW
SetupRenameErrorW.restype = wintypes.DWORD
SetupRenameErrorW.argtypes = [
wintypes.HANDLE, # hwndParent : HWND
wintypes.LPCWSTR, # DialogTitle : LPCWSTR optional
wintypes.LPCWSTR, # SourceFile : LPCWSTR
wintypes.LPCWSTR, # TargetFile : LPCWSTR
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')
SetupRenameErrorW = Fiddle::Function.new(
lib['SetupRenameErrorW'],
[
Fiddle::TYPE_VOIDP, # hwndParent : HWND
Fiddle::TYPE_VOIDP, # DialogTitle : LPCWSTR optional
Fiddle::TYPE_VOIDP, # SourceFile : LPCWSTR
Fiddle::TYPE_VOIDP, # TargetFile : LPCWSTR
-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 SetupRenameErrorW(
hwndParent: *mut core::ffi::c_void, // HWND
DialogTitle: *const u16, // LPCWSTR optional
SourceFile: *const u16, // LPCWSTR
TargetFile: *const u16, // LPCWSTR
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 SetupRenameErrorW(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_SetupRenameErrorW' -Namespace Win32 -PassThru
# $api::SetupRenameErrorW(hwndParent, DialogTitle, SourceFile, TargetFile, Win32ErrorCode, Style)#uselib "SETUPAPI.dll"
#func global SetupRenameErrorW "SetupRenameErrorW" wptr, wptr, wptr, wptr, wptr, wptr
; SetupRenameErrorW hwndParent, DialogTitle, SourceFile, TargetFile, Win32ErrorCode, Style ; 戻り値は stat
; hwndParent : HWND -> "wptr"
; DialogTitle : LPCWSTR optional -> "wptr"
; SourceFile : LPCWSTR -> "wptr"
; TargetFile : LPCWSTR -> "wptr"
; Win32ErrorCode : DWORD -> "wptr"
; Style : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "SETUPAPI.dll"
#cfunc global SetupRenameErrorW "SetupRenameErrorW" sptr, wstr, wstr, wstr, int, int
; res = SetupRenameErrorW(hwndParent, DialogTitle, SourceFile, TargetFile, Win32ErrorCode, Style)
; hwndParent : HWND -> "sptr"
; DialogTitle : LPCWSTR optional -> "wstr"
; SourceFile : LPCWSTR -> "wstr"
; TargetFile : LPCWSTR -> "wstr"
; Win32ErrorCode : DWORD -> "int"
; Style : DWORD -> "int"; DWORD SetupRenameErrorW(HWND hwndParent, LPCWSTR DialogTitle, LPCWSTR SourceFile, LPCWSTR TargetFile, DWORD Win32ErrorCode, DWORD Style)
#uselib "SETUPAPI.dll"
#cfunc global SetupRenameErrorW "SetupRenameErrorW" intptr, wstr, wstr, wstr, int, int
; res = SetupRenameErrorW(hwndParent, DialogTitle, SourceFile, TargetFile, Win32ErrorCode, Style)
; hwndParent : HWND -> "intptr"
; DialogTitle : LPCWSTR optional -> "wstr"
; SourceFile : LPCWSTR -> "wstr"
; TargetFile : LPCWSTR -> "wstr"
; Win32ErrorCode : DWORD -> "int"
; Style : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
procSetupRenameErrorW = setupapi.NewProc("SetupRenameErrorW")
)
// hwndParent (HWND), DialogTitle (LPCWSTR optional), SourceFile (LPCWSTR), TargetFile (LPCWSTR), Win32ErrorCode (DWORD), Style (DWORD)
r1, _, err := procSetupRenameErrorW.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 // DWORDfunction SetupRenameErrorW(
hwndParent: THandle; // HWND
DialogTitle: PWideChar; // LPCWSTR optional
SourceFile: PWideChar; // LPCWSTR
TargetFile: PWideChar; // LPCWSTR
Win32ErrorCode: DWORD; // DWORD
Style: DWORD // DWORD
): DWORD; stdcall;
external 'SETUPAPI.dll' name 'SetupRenameErrorW';result := DllCall("SETUPAPI\SetupRenameErrorW"
, "Ptr", hwndParent ; HWND
, "WStr", DialogTitle ; LPCWSTR optional
, "WStr", SourceFile ; LPCWSTR
, "WStr", TargetFile ; LPCWSTR
, "UInt", Win32ErrorCode ; DWORD
, "UInt", Style ; DWORD
, "UInt") ; return: DWORD●SetupRenameErrorW(hwndParent, DialogTitle, SourceFile, TargetFile, Win32ErrorCode, Style) = DLL("SETUPAPI.dll", "dword SetupRenameErrorW(void*, char*, char*, char*, dword, dword)")
# 呼び出し: SetupRenameErrorW(hwndParent, DialogTitle, SourceFile, TargetFile, Win32ErrorCode, Style)
# hwndParent : HWND -> "void*"
# DialogTitle : LPCWSTR optional -> "char*"
# SourceFile : LPCWSTR -> "char*"
# TargetFile : LPCWSTR -> "char*"
# Win32ErrorCode : DWORD -> "dword"
# Style : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。