ホーム › Devices.DeviceAndDriverInstallation › SetupDeleteErrorW
SetupDeleteErrorW
関数ファイル削除エラーを通知するダイアログを表示する(Unicode)。
シグネチャ
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
DWORD SetupDeleteErrorW(
HWND hwndParent,
LPCWSTR DialogTitle, // optional
LPCWSTR File,
DWORD Win32ErrorCode,
DWORD Style
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hwndParent | HWND | in | エラーダイアログの親ウィンドウハンドル。NULL可。 |
| DialogTitle | LPCWSTR | inoptional | ダイアログのタイトル文字列(Unicode)。NULLで既定値を使う。 |
| File | LPCWSTR | in | 削除対象のファイル名(Unicode)。 |
| Win32ErrorCode | DWORD | in | 発生したWin32エラーコード。表示メッセージの決定に使う。 |
| Style | DWORD | in | ダイアログの表示動作を制御するスタイルフラグ。 |
戻り値の型: DWORD
各言語での呼び出し定義
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
DWORD SetupDeleteErrorW(
HWND hwndParent,
LPCWSTR DialogTitle, // optional
LPCWSTR File,
DWORD Win32ErrorCode,
DWORD Style
);[DllImport("SETUPAPI.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern uint SetupDeleteErrorW(
IntPtr hwndParent, // HWND
[MarshalAs(UnmanagedType.LPWStr)] string DialogTitle, // LPCWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string File, // LPCWSTR
uint Win32ErrorCode, // DWORD
uint Style // DWORD
);<DllImport("SETUPAPI.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupDeleteErrorW(
hwndParent As IntPtr, ' HWND
<MarshalAs(UnmanagedType.LPWStr)> DialogTitle As String, ' LPCWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> File As String, ' LPCWSTR
Win32ErrorCode As UInteger, ' DWORD
Style As UInteger ' DWORD
) As UInteger
End Function' hwndParent : HWND
' DialogTitle : LPCWSTR optional
' File : LPCWSTR
' Win32ErrorCode : DWORD
' Style : DWORD
Declare PtrSafe Function SetupDeleteErrorW Lib "setupapi" ( _
ByVal hwndParent As LongPtr, _
ByVal DialogTitle As LongPtr, _
ByVal File 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
SetupDeleteErrorW = ctypes.windll.setupapi.SetupDeleteErrorW
SetupDeleteErrorW.restype = wintypes.DWORD
SetupDeleteErrorW.argtypes = [
wintypes.HANDLE, # hwndParent : HWND
wintypes.LPCWSTR, # DialogTitle : LPCWSTR optional
wintypes.LPCWSTR, # File : 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')
SetupDeleteErrorW = Fiddle::Function.new(
lib['SetupDeleteErrorW'],
[
Fiddle::TYPE_VOIDP, # hwndParent : HWND
Fiddle::TYPE_VOIDP, # DialogTitle : LPCWSTR optional
Fiddle::TYPE_VOIDP, # File : 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 SetupDeleteErrorW(
hwndParent: *mut core::ffi::c_void, // HWND
DialogTitle: *const u16, // LPCWSTR optional
File: *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 SetupDeleteErrorW(IntPtr hwndParent, [MarshalAs(UnmanagedType.LPWStr)] string DialogTitle, [MarshalAs(UnmanagedType.LPWStr)] string File, uint Win32ErrorCode, uint Style);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupDeleteErrorW' -Namespace Win32 -PassThru
# $api::SetupDeleteErrorW(hwndParent, DialogTitle, File, Win32ErrorCode, Style)#uselib "SETUPAPI.dll"
#func global SetupDeleteErrorW "SetupDeleteErrorW" wptr, wptr, wptr, wptr, wptr
; SetupDeleteErrorW hwndParent, DialogTitle, File, Win32ErrorCode, Style ; 戻り値は stat
; hwndParent : HWND -> "wptr"
; DialogTitle : LPCWSTR optional -> "wptr"
; File : LPCWSTR -> "wptr"
; Win32ErrorCode : DWORD -> "wptr"
; Style : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "SETUPAPI.dll"
#cfunc global SetupDeleteErrorW "SetupDeleteErrorW" sptr, wstr, wstr, int, int
; res = SetupDeleteErrorW(hwndParent, DialogTitle, File, Win32ErrorCode, Style)
; hwndParent : HWND -> "sptr"
; DialogTitle : LPCWSTR optional -> "wstr"
; File : LPCWSTR -> "wstr"
; Win32ErrorCode : DWORD -> "int"
; Style : DWORD -> "int"; DWORD SetupDeleteErrorW(HWND hwndParent, LPCWSTR DialogTitle, LPCWSTR File, DWORD Win32ErrorCode, DWORD Style)
#uselib "SETUPAPI.dll"
#cfunc global SetupDeleteErrorW "SetupDeleteErrorW" intptr, wstr, wstr, int, int
; res = SetupDeleteErrorW(hwndParent, DialogTitle, File, Win32ErrorCode, Style)
; hwndParent : HWND -> "intptr"
; DialogTitle : LPCWSTR optional -> "wstr"
; File : LPCWSTR -> "wstr"
; Win32ErrorCode : DWORD -> "int"
; Style : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
procSetupDeleteErrorW = setupapi.NewProc("SetupDeleteErrorW")
)
// hwndParent (HWND), DialogTitle (LPCWSTR optional), File (LPCWSTR), Win32ErrorCode (DWORD), Style (DWORD)
r1, _, err := procSetupDeleteErrorW.Call(
uintptr(hwndParent),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(DialogTitle))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(File))),
uintptr(Win32ErrorCode),
uintptr(Style),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction SetupDeleteErrorW(
hwndParent: THandle; // HWND
DialogTitle: PWideChar; // LPCWSTR optional
File: PWideChar; // LPCWSTR
Win32ErrorCode: DWORD; // DWORD
Style: DWORD // DWORD
): DWORD; stdcall;
external 'SETUPAPI.dll' name 'SetupDeleteErrorW';result := DllCall("SETUPAPI\SetupDeleteErrorW"
, "Ptr", hwndParent ; HWND
, "WStr", DialogTitle ; LPCWSTR optional
, "WStr", File ; LPCWSTR
, "UInt", Win32ErrorCode ; DWORD
, "UInt", Style ; DWORD
, "UInt") ; return: DWORD●SetupDeleteErrorW(hwndParent, DialogTitle, File, Win32ErrorCode, Style) = DLL("SETUPAPI.dll", "dword SetupDeleteErrorW(void*, char*, char*, dword, dword)")
# 呼び出し: SetupDeleteErrorW(hwndParent, DialogTitle, File, Win32ErrorCode, Style)
# hwndParent : HWND -> "void*"
# DialogTitle : LPCWSTR optional -> "char*"
# File : LPCWSTR -> "char*"
# Win32ErrorCode : DWORD -> "dword"
# Style : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。