ホーム › Devices.DeviceAndDriverInstallation › SetupPromptForDiskW
SetupPromptForDiskW
関数ソースディスクの挿入を求めるダイアログを表示する(Unicode)。
シグネチャ
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
DWORD SetupPromptForDiskW(
HWND hwndParent,
LPCWSTR DialogTitle, // optional
LPCWSTR DiskName, // optional
LPCWSTR PathToSource, // optional
LPCWSTR FileSought,
LPCWSTR TagFile, // optional
DWORD DiskPromptStyle,
LPWSTR PathBuffer, // optional
DWORD PathBufferSize,
DWORD* PathRequiredSize // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hwndParent | HWND | in |
| DialogTitle | LPCWSTR | inoptional |
| DiskName | LPCWSTR | inoptional |
| PathToSource | LPCWSTR | inoptional |
| FileSought | LPCWSTR | in |
| TagFile | LPCWSTR | inoptional |
| DiskPromptStyle | DWORD | in |
| PathBuffer | LPWSTR | outoptional |
| PathBufferSize | DWORD | in |
| PathRequiredSize | DWORD* | outoptional |
戻り値の型: DWORD
各言語での呼び出し定義
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
DWORD SetupPromptForDiskW(
HWND hwndParent,
LPCWSTR DialogTitle, // optional
LPCWSTR DiskName, // optional
LPCWSTR PathToSource, // optional
LPCWSTR FileSought,
LPCWSTR TagFile, // optional
DWORD DiskPromptStyle,
LPWSTR PathBuffer, // optional
DWORD PathBufferSize,
DWORD* PathRequiredSize // optional
);[DllImport("SETUPAPI.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern uint SetupPromptForDiskW(
IntPtr hwndParent, // HWND
[MarshalAs(UnmanagedType.LPWStr)] string DialogTitle, // LPCWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string DiskName, // LPCWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string PathToSource, // LPCWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string FileSought, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string TagFile, // LPCWSTR optional
uint DiskPromptStyle, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder PathBuffer, // LPWSTR optional, out
uint PathBufferSize, // DWORD
IntPtr PathRequiredSize // DWORD* optional, out
);<DllImport("SETUPAPI.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupPromptForDiskW(
hwndParent As IntPtr, ' HWND
<MarshalAs(UnmanagedType.LPWStr)> DialogTitle As String, ' LPCWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> DiskName As String, ' LPCWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> PathToSource As String, ' LPCWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> FileSought As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> TagFile As String, ' LPCWSTR optional
DiskPromptStyle As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> PathBuffer As System.Text.StringBuilder, ' LPWSTR optional, out
PathBufferSize As UInteger, ' DWORD
PathRequiredSize As IntPtr ' DWORD* optional, out
) As UInteger
End Function' hwndParent : HWND
' DialogTitle : LPCWSTR optional
' DiskName : LPCWSTR optional
' PathToSource : LPCWSTR optional
' FileSought : LPCWSTR
' TagFile : LPCWSTR optional
' DiskPromptStyle : DWORD
' PathBuffer : LPWSTR optional, out
' PathBufferSize : DWORD
' PathRequiredSize : DWORD* optional, out
Declare PtrSafe Function SetupPromptForDiskW Lib "setupapi" ( _
ByVal hwndParent As LongPtr, _
ByVal DialogTitle As LongPtr, _
ByVal DiskName As LongPtr, _
ByVal PathToSource As LongPtr, _
ByVal FileSought As LongPtr, _
ByVal TagFile As LongPtr, _
ByVal DiskPromptStyle As Long, _
ByVal PathBuffer As LongPtr, _
ByVal PathBufferSize As Long, _
ByVal PathRequiredSize As LongPtr) 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
SetupPromptForDiskW = ctypes.windll.setupapi.SetupPromptForDiskW
SetupPromptForDiskW.restype = wintypes.DWORD
SetupPromptForDiskW.argtypes = [
wintypes.HANDLE, # hwndParent : HWND
wintypes.LPCWSTR, # DialogTitle : LPCWSTR optional
wintypes.LPCWSTR, # DiskName : LPCWSTR optional
wintypes.LPCWSTR, # PathToSource : LPCWSTR optional
wintypes.LPCWSTR, # FileSought : LPCWSTR
wintypes.LPCWSTR, # TagFile : LPCWSTR optional
wintypes.DWORD, # DiskPromptStyle : DWORD
wintypes.LPWSTR, # PathBuffer : LPWSTR optional, out
wintypes.DWORD, # PathBufferSize : DWORD
ctypes.POINTER(wintypes.DWORD), # PathRequiredSize : DWORD* optional, out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SETUPAPI.dll')
SetupPromptForDiskW = Fiddle::Function.new(
lib['SetupPromptForDiskW'],
[
Fiddle::TYPE_VOIDP, # hwndParent : HWND
Fiddle::TYPE_VOIDP, # DialogTitle : LPCWSTR optional
Fiddle::TYPE_VOIDP, # DiskName : LPCWSTR optional
Fiddle::TYPE_VOIDP, # PathToSource : LPCWSTR optional
Fiddle::TYPE_VOIDP, # FileSought : LPCWSTR
Fiddle::TYPE_VOIDP, # TagFile : LPCWSTR optional
-Fiddle::TYPE_INT, # DiskPromptStyle : DWORD
Fiddle::TYPE_VOIDP, # PathBuffer : LPWSTR optional, out
-Fiddle::TYPE_INT, # PathBufferSize : DWORD
Fiddle::TYPE_VOIDP, # PathRequiredSize : DWORD* optional, out
],
-Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "setupapi")]
extern "system" {
fn SetupPromptForDiskW(
hwndParent: *mut core::ffi::c_void, // HWND
DialogTitle: *const u16, // LPCWSTR optional
DiskName: *const u16, // LPCWSTR optional
PathToSource: *const u16, // LPCWSTR optional
FileSought: *const u16, // LPCWSTR
TagFile: *const u16, // LPCWSTR optional
DiskPromptStyle: u32, // DWORD
PathBuffer: *mut u16, // LPWSTR optional, out
PathBufferSize: u32, // DWORD
PathRequiredSize: *mut u32 // DWORD* optional, out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SETUPAPI.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern uint SetupPromptForDiskW(IntPtr hwndParent, [MarshalAs(UnmanagedType.LPWStr)] string DialogTitle, [MarshalAs(UnmanagedType.LPWStr)] string DiskName, [MarshalAs(UnmanagedType.LPWStr)] string PathToSource, [MarshalAs(UnmanagedType.LPWStr)] string FileSought, [MarshalAs(UnmanagedType.LPWStr)] string TagFile, uint DiskPromptStyle, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder PathBuffer, uint PathBufferSize, IntPtr PathRequiredSize);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupPromptForDiskW' -Namespace Win32 -PassThru
# $api::SetupPromptForDiskW(hwndParent, DialogTitle, DiskName, PathToSource, FileSought, TagFile, DiskPromptStyle, PathBuffer, PathBufferSize, PathRequiredSize)#uselib "SETUPAPI.dll"
#func global SetupPromptForDiskW "SetupPromptForDiskW" wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr
; SetupPromptForDiskW hwndParent, DialogTitle, DiskName, PathToSource, FileSought, TagFile, DiskPromptStyle, varptr(PathBuffer), PathBufferSize, varptr(PathRequiredSize) ; 戻り値は stat
; hwndParent : HWND -> "wptr"
; DialogTitle : LPCWSTR optional -> "wptr"
; DiskName : LPCWSTR optional -> "wptr"
; PathToSource : LPCWSTR optional -> "wptr"
; FileSought : LPCWSTR -> "wptr"
; TagFile : LPCWSTR optional -> "wptr"
; DiskPromptStyle : DWORD -> "wptr"
; PathBuffer : LPWSTR optional, out -> "wptr"
; PathBufferSize : DWORD -> "wptr"
; PathRequiredSize : DWORD* optional, out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SETUPAPI.dll" #cfunc global SetupPromptForDiskW "SetupPromptForDiskW" sptr, wstr, wstr, wstr, wstr, wstr, int, var, int, var ; res = SetupPromptForDiskW(hwndParent, DialogTitle, DiskName, PathToSource, FileSought, TagFile, DiskPromptStyle, PathBuffer, PathBufferSize, PathRequiredSize) ; hwndParent : HWND -> "sptr" ; DialogTitle : LPCWSTR optional -> "wstr" ; DiskName : LPCWSTR optional -> "wstr" ; PathToSource : LPCWSTR optional -> "wstr" ; FileSought : LPCWSTR -> "wstr" ; TagFile : LPCWSTR optional -> "wstr" ; DiskPromptStyle : DWORD -> "int" ; PathBuffer : LPWSTR optional, out -> "var" ; PathBufferSize : DWORD -> "int" ; PathRequiredSize : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SETUPAPI.dll" #cfunc global SetupPromptForDiskW "SetupPromptForDiskW" sptr, wstr, wstr, wstr, wstr, wstr, int, sptr, int, sptr ; res = SetupPromptForDiskW(hwndParent, DialogTitle, DiskName, PathToSource, FileSought, TagFile, DiskPromptStyle, varptr(PathBuffer), PathBufferSize, varptr(PathRequiredSize)) ; hwndParent : HWND -> "sptr" ; DialogTitle : LPCWSTR optional -> "wstr" ; DiskName : LPCWSTR optional -> "wstr" ; PathToSource : LPCWSTR optional -> "wstr" ; FileSought : LPCWSTR -> "wstr" ; TagFile : LPCWSTR optional -> "wstr" ; DiskPromptStyle : DWORD -> "int" ; PathBuffer : LPWSTR optional, out -> "sptr" ; PathBufferSize : DWORD -> "int" ; PathRequiredSize : DWORD* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD SetupPromptForDiskW(HWND hwndParent, LPCWSTR DialogTitle, LPCWSTR DiskName, LPCWSTR PathToSource, LPCWSTR FileSought, LPCWSTR TagFile, DWORD DiskPromptStyle, LPWSTR PathBuffer, DWORD PathBufferSize, DWORD* PathRequiredSize) #uselib "SETUPAPI.dll" #cfunc global SetupPromptForDiskW "SetupPromptForDiskW" intptr, wstr, wstr, wstr, wstr, wstr, int, var, int, var ; res = SetupPromptForDiskW(hwndParent, DialogTitle, DiskName, PathToSource, FileSought, TagFile, DiskPromptStyle, PathBuffer, PathBufferSize, PathRequiredSize) ; hwndParent : HWND -> "intptr" ; DialogTitle : LPCWSTR optional -> "wstr" ; DiskName : LPCWSTR optional -> "wstr" ; PathToSource : LPCWSTR optional -> "wstr" ; FileSought : LPCWSTR -> "wstr" ; TagFile : LPCWSTR optional -> "wstr" ; DiskPromptStyle : DWORD -> "int" ; PathBuffer : LPWSTR optional, out -> "var" ; PathBufferSize : DWORD -> "int" ; PathRequiredSize : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD SetupPromptForDiskW(HWND hwndParent, LPCWSTR DialogTitle, LPCWSTR DiskName, LPCWSTR PathToSource, LPCWSTR FileSought, LPCWSTR TagFile, DWORD DiskPromptStyle, LPWSTR PathBuffer, DWORD PathBufferSize, DWORD* PathRequiredSize) #uselib "SETUPAPI.dll" #cfunc global SetupPromptForDiskW "SetupPromptForDiskW" intptr, wstr, wstr, wstr, wstr, wstr, int, intptr, int, intptr ; res = SetupPromptForDiskW(hwndParent, DialogTitle, DiskName, PathToSource, FileSought, TagFile, DiskPromptStyle, varptr(PathBuffer), PathBufferSize, varptr(PathRequiredSize)) ; hwndParent : HWND -> "intptr" ; DialogTitle : LPCWSTR optional -> "wstr" ; DiskName : LPCWSTR optional -> "wstr" ; PathToSource : LPCWSTR optional -> "wstr" ; FileSought : LPCWSTR -> "wstr" ; TagFile : LPCWSTR optional -> "wstr" ; DiskPromptStyle : DWORD -> "int" ; PathBuffer : LPWSTR optional, out -> "intptr" ; PathBufferSize : DWORD -> "int" ; PathRequiredSize : DWORD* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
procSetupPromptForDiskW = setupapi.NewProc("SetupPromptForDiskW")
)
// hwndParent (HWND), DialogTitle (LPCWSTR optional), DiskName (LPCWSTR optional), PathToSource (LPCWSTR optional), FileSought (LPCWSTR), TagFile (LPCWSTR optional), DiskPromptStyle (DWORD), PathBuffer (LPWSTR optional, out), PathBufferSize (DWORD), PathRequiredSize (DWORD* optional, out)
r1, _, err := procSetupPromptForDiskW.Call(
uintptr(hwndParent),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(DialogTitle))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(DiskName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(PathToSource))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(FileSought))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(TagFile))),
uintptr(DiskPromptStyle),
uintptr(PathBuffer),
uintptr(PathBufferSize),
uintptr(PathRequiredSize),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction SetupPromptForDiskW(
hwndParent: THandle; // HWND
DialogTitle: PWideChar; // LPCWSTR optional
DiskName: PWideChar; // LPCWSTR optional
PathToSource: PWideChar; // LPCWSTR optional
FileSought: PWideChar; // LPCWSTR
TagFile: PWideChar; // LPCWSTR optional
DiskPromptStyle: DWORD; // DWORD
PathBuffer: PWideChar; // LPWSTR optional, out
PathBufferSize: DWORD; // DWORD
PathRequiredSize: Pointer // DWORD* optional, out
): DWORD; stdcall;
external 'SETUPAPI.dll' name 'SetupPromptForDiskW';result := DllCall("SETUPAPI\SetupPromptForDiskW"
, "Ptr", hwndParent ; HWND
, "WStr", DialogTitle ; LPCWSTR optional
, "WStr", DiskName ; LPCWSTR optional
, "WStr", PathToSource ; LPCWSTR optional
, "WStr", FileSought ; LPCWSTR
, "WStr", TagFile ; LPCWSTR optional
, "UInt", DiskPromptStyle ; DWORD
, "Ptr", PathBuffer ; LPWSTR optional, out
, "UInt", PathBufferSize ; DWORD
, "Ptr", PathRequiredSize ; DWORD* optional, out
, "UInt") ; return: DWORD●SetupPromptForDiskW(hwndParent, DialogTitle, DiskName, PathToSource, FileSought, TagFile, DiskPromptStyle, PathBuffer, PathBufferSize, PathRequiredSize) = DLL("SETUPAPI.dll", "dword SetupPromptForDiskW(void*, char*, char*, char*, char*, char*, dword, char*, dword, void*)")
# 呼び出し: SetupPromptForDiskW(hwndParent, DialogTitle, DiskName, PathToSource, FileSought, TagFile, DiskPromptStyle, PathBuffer, PathBufferSize, PathRequiredSize)
# hwndParent : HWND -> "void*"
# DialogTitle : LPCWSTR optional -> "char*"
# DiskName : LPCWSTR optional -> "char*"
# PathToSource : LPCWSTR optional -> "char*"
# FileSought : LPCWSTR -> "char*"
# TagFile : LPCWSTR optional -> "char*"
# DiskPromptStyle : DWORD -> "dword"
# PathBuffer : LPWSTR optional, out -> "char*"
# PathBufferSize : DWORD -> "dword"
# PathRequiredSize : DWORD* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。