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