Win32 API 日本語リファレンス
ホームDevices.DeviceAndDriverInstallation › SetupPromptForDiskA

SetupPromptForDiskA

関数
ソースディスクの挿入を求めるダイアログを表示する(ANSI)。
DLLSETUPAPI.dll文字セットANSI (-A)呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

// SETUPAPI.dll  (ANSI / -A)
#include <windows.h>

DWORD SetupPromptForDiskA(
    HWND hwndParent,
    LPCSTR DialogTitle,   // optional
    LPCSTR DiskName,   // optional
    LPCSTR PathToSource,   // optional
    LPCSTR FileSought,
    LPCSTR TagFile,   // optional
    DWORD DiskPromptStyle,
    LPSTR PathBuffer,   // optional
    DWORD PathBufferSize,
    DWORD* PathRequiredSize   // optional
);

パラメーター

名前方向
hwndParentHWNDin
DialogTitleLPCSTRinoptional
DiskNameLPCSTRinoptional
PathToSourceLPCSTRinoptional
FileSoughtLPCSTRin
TagFileLPCSTRinoptional
DiskPromptStyleDWORDin
PathBufferLPSTRoutoptional
PathBufferSizeDWORDin
PathRequiredSizeDWORD*outoptional

戻り値の型: DWORD

各言語での呼び出し定義

// SETUPAPI.dll  (ANSI / -A)
#include <windows.h>

DWORD SetupPromptForDiskA(
    HWND hwndParent,
    LPCSTR DialogTitle,   // optional
    LPCSTR DiskName,   // optional
    LPCSTR PathToSource,   // optional
    LPCSTR FileSought,
    LPCSTR TagFile,   // optional
    DWORD DiskPromptStyle,
    LPSTR PathBuffer,   // optional
    DWORD PathBufferSize,
    DWORD* PathRequiredSize   // optional
);
[DllImport("SETUPAPI.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern uint SetupPromptForDiskA(
    IntPtr hwndParent,   // HWND
    [MarshalAs(UnmanagedType.LPStr)] string DialogTitle,   // LPCSTR optional
    [MarshalAs(UnmanagedType.LPStr)] string DiskName,   // LPCSTR optional
    [MarshalAs(UnmanagedType.LPStr)] string PathToSource,   // LPCSTR optional
    [MarshalAs(UnmanagedType.LPStr)] string FileSought,   // LPCSTR
    [MarshalAs(UnmanagedType.LPStr)] string TagFile,   // LPCSTR optional
    uint DiskPromptStyle,   // DWORD
    [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder PathBuffer,   // LPSTR optional, out
    uint PathBufferSize,   // DWORD
    IntPtr PathRequiredSize   // DWORD* optional, out
);
<DllImport("SETUPAPI.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupPromptForDiskA(
    hwndParent As IntPtr,   ' HWND
    <MarshalAs(UnmanagedType.LPStr)> DialogTitle As String,   ' LPCSTR optional
    <MarshalAs(UnmanagedType.LPStr)> DiskName As String,   ' LPCSTR optional
    <MarshalAs(UnmanagedType.LPStr)> PathToSource As String,   ' LPCSTR optional
    <MarshalAs(UnmanagedType.LPStr)> FileSought As String,   ' LPCSTR
    <MarshalAs(UnmanagedType.LPStr)> TagFile As String,   ' LPCSTR optional
    DiskPromptStyle As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPStr)> PathBuffer As System.Text.StringBuilder,   ' LPSTR optional, out
    PathBufferSize As UInteger,   ' DWORD
    PathRequiredSize As IntPtr   ' DWORD* optional, out
) As UInteger
End Function
' hwndParent : HWND
' DialogTitle : LPCSTR optional
' DiskName : LPCSTR optional
' PathToSource : LPCSTR optional
' FileSought : LPCSTR
' TagFile : LPCSTR optional
' DiskPromptStyle : DWORD
' PathBuffer : LPSTR optional, out
' PathBufferSize : DWORD
' PathRequiredSize : DWORD* optional, out
Declare PtrSafe Function SetupPromptForDiskA Lib "setupapi" ( _
    ByVal hwndParent As LongPtr, _
    ByVal DialogTitle As String, _
    ByVal DiskName As String, _
    ByVal PathToSource As String, _
    ByVal FileSought As String, _
    ByVal TagFile As String, _
    ByVal DiskPromptStyle As Long, _
    ByVal PathBuffer As String, _
    ByVal PathBufferSize As Long, _
    ByVal PathRequiredSize As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SetupPromptForDiskA = ctypes.windll.setupapi.SetupPromptForDiskA
SetupPromptForDiskA.restype = wintypes.DWORD
SetupPromptForDiskA.argtypes = [
    wintypes.HANDLE,  # hwndParent : HWND
    wintypes.LPCSTR,  # DialogTitle : LPCSTR optional
    wintypes.LPCSTR,  # DiskName : LPCSTR optional
    wintypes.LPCSTR,  # PathToSource : LPCSTR optional
    wintypes.LPCSTR,  # FileSought : LPCSTR
    wintypes.LPCSTR,  # TagFile : LPCSTR optional
    wintypes.DWORD,  # DiskPromptStyle : DWORD
    wintypes.LPSTR,  # PathBuffer : LPSTR 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')
SetupPromptForDiskA = Fiddle::Function.new(
  lib['SetupPromptForDiskA'],
  [
    Fiddle::TYPE_VOIDP,  # hwndParent : HWND
    Fiddle::TYPE_VOIDP,  # DialogTitle : LPCSTR optional
    Fiddle::TYPE_VOIDP,  # DiskName : LPCSTR optional
    Fiddle::TYPE_VOIDP,  # PathToSource : LPCSTR optional
    Fiddle::TYPE_VOIDP,  # FileSought : LPCSTR
    Fiddle::TYPE_VOIDP,  # TagFile : LPCSTR optional
    -Fiddle::TYPE_INT,  # DiskPromptStyle : DWORD
    Fiddle::TYPE_VOIDP,  # PathBuffer : LPSTR optional, out
    -Fiddle::TYPE_INT,  # PathBufferSize : DWORD
    Fiddle::TYPE_VOIDP,  # PathRequiredSize : DWORD* optional, out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "setupapi")]
extern "system" {
    fn SetupPromptForDiskA(
        hwndParent: *mut core::ffi::c_void,  // HWND
        DialogTitle: *const u8,  // LPCSTR optional
        DiskName: *const u8,  // LPCSTR optional
        PathToSource: *const u8,  // LPCSTR optional
        FileSought: *const u8,  // LPCSTR
        TagFile: *const u8,  // LPCSTR optional
        DiskPromptStyle: u32,  // DWORD
        PathBuffer: *mut u8,  // LPSTR 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.Ansi, SetLastError = true)]
public static extern uint SetupPromptForDiskA(IntPtr hwndParent, [MarshalAs(UnmanagedType.LPStr)] string DialogTitle, [MarshalAs(UnmanagedType.LPStr)] string DiskName, [MarshalAs(UnmanagedType.LPStr)] string PathToSource, [MarshalAs(UnmanagedType.LPStr)] string FileSought, [MarshalAs(UnmanagedType.LPStr)] string TagFile, uint DiskPromptStyle, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder PathBuffer, uint PathBufferSize, IntPtr PathRequiredSize);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupPromptForDiskA' -Namespace Win32 -PassThru
# $api::SetupPromptForDiskA(hwndParent, DialogTitle, DiskName, PathToSource, FileSought, TagFile, DiskPromptStyle, PathBuffer, PathBufferSize, PathRequiredSize)
#uselib "SETUPAPI.dll"
#func global SetupPromptForDiskA "SetupPromptForDiskA" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; SetupPromptForDiskA hwndParent, DialogTitle, DiskName, PathToSource, FileSought, TagFile, DiskPromptStyle, varptr(PathBuffer), PathBufferSize, varptr(PathRequiredSize)   ; 戻り値は stat
; hwndParent : HWND -> "sptr"
; DialogTitle : LPCSTR optional -> "sptr"
; DiskName : LPCSTR optional -> "sptr"
; PathToSource : LPCSTR optional -> "sptr"
; FileSought : LPCSTR -> "sptr"
; TagFile : LPCSTR optional -> "sptr"
; DiskPromptStyle : DWORD -> "sptr"
; PathBuffer : LPSTR optional, out -> "sptr"
; PathBufferSize : DWORD -> "sptr"
; PathRequiredSize : DWORD* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "SETUPAPI.dll"
#cfunc global SetupPromptForDiskA "SetupPromptForDiskA" sptr, str, str, str, str, str, int, var, int, var
; res = SetupPromptForDiskA(hwndParent, DialogTitle, DiskName, PathToSource, FileSought, TagFile, DiskPromptStyle, PathBuffer, PathBufferSize, PathRequiredSize)
; hwndParent : HWND -> "sptr"
; DialogTitle : LPCSTR optional -> "str"
; DiskName : LPCSTR optional -> "str"
; PathToSource : LPCSTR optional -> "str"
; FileSought : LPCSTR -> "str"
; TagFile : LPCSTR optional -> "str"
; DiskPromptStyle : DWORD -> "int"
; PathBuffer : LPSTR optional, out -> "var"
; PathBufferSize : DWORD -> "int"
; PathRequiredSize : DWORD* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD SetupPromptForDiskA(HWND hwndParent, LPCSTR DialogTitle, LPCSTR DiskName, LPCSTR PathToSource, LPCSTR FileSought, LPCSTR TagFile, DWORD DiskPromptStyle, LPSTR PathBuffer, DWORD PathBufferSize, DWORD* PathRequiredSize)
#uselib "SETUPAPI.dll"
#cfunc global SetupPromptForDiskA "SetupPromptForDiskA" intptr, str, str, str, str, str, int, var, int, var
; res = SetupPromptForDiskA(hwndParent, DialogTitle, DiskName, PathToSource, FileSought, TagFile, DiskPromptStyle, PathBuffer, PathBufferSize, PathRequiredSize)
; hwndParent : HWND -> "intptr"
; DialogTitle : LPCSTR optional -> "str"
; DiskName : LPCSTR optional -> "str"
; PathToSource : LPCSTR optional -> "str"
; FileSought : LPCSTR -> "str"
; TagFile : LPCSTR optional -> "str"
; DiskPromptStyle : DWORD -> "int"
; PathBuffer : LPSTR optional, out -> "var"
; PathBufferSize : DWORD -> "int"
; PathRequiredSize : DWORD* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
	procSetupPromptForDiskA = setupapi.NewProc("SetupPromptForDiskA")
)

// hwndParent (HWND), DialogTitle (LPCSTR optional), DiskName (LPCSTR optional), PathToSource (LPCSTR optional), FileSought (LPCSTR), TagFile (LPCSTR optional), DiskPromptStyle (DWORD), PathBuffer (LPSTR optional, out), PathBufferSize (DWORD), PathRequiredSize (DWORD* optional, out)
r1, _, err := procSetupPromptForDiskA.Call(
	uintptr(hwndParent),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(DialogTitle))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(DiskName))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(PathToSource))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(FileSought))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(TagFile))),
	uintptr(DiskPromptStyle),
	uintptr(PathBuffer),
	uintptr(PathBufferSize),
	uintptr(PathRequiredSize),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function SetupPromptForDiskA(
  hwndParent: THandle;   // HWND
  DialogTitle: PAnsiChar;   // LPCSTR optional
  DiskName: PAnsiChar;   // LPCSTR optional
  PathToSource: PAnsiChar;   // LPCSTR optional
  FileSought: PAnsiChar;   // LPCSTR
  TagFile: PAnsiChar;   // LPCSTR optional
  DiskPromptStyle: DWORD;   // DWORD
  PathBuffer: PAnsiChar;   // LPSTR optional, out
  PathBufferSize: DWORD;   // DWORD
  PathRequiredSize: Pointer   // DWORD* optional, out
): DWORD; stdcall;
  external 'SETUPAPI.dll' name 'SetupPromptForDiskA';
result := DllCall("SETUPAPI\SetupPromptForDiskA"
    , "Ptr", hwndParent   ; HWND
    , "AStr", DialogTitle   ; LPCSTR optional
    , "AStr", DiskName   ; LPCSTR optional
    , "AStr", PathToSource   ; LPCSTR optional
    , "AStr", FileSought   ; LPCSTR
    , "AStr", TagFile   ; LPCSTR optional
    , "UInt", DiskPromptStyle   ; DWORD
    , "Ptr", PathBuffer   ; LPSTR optional, out
    , "UInt", PathBufferSize   ; DWORD
    , "Ptr", PathRequiredSize   ; DWORD* optional, out
    , "UInt")   ; return: DWORD
●SetupPromptForDiskA(hwndParent, DialogTitle, DiskName, PathToSource, FileSought, TagFile, DiskPromptStyle, PathBuffer, PathBufferSize, PathRequiredSize) = DLL("SETUPAPI.dll", "dword SetupPromptForDiskA(void*, char*, char*, char*, char*, char*, dword, char*, dword, void*)")
# 呼び出し: SetupPromptForDiskA(hwndParent, DialogTitle, DiskName, PathToSource, FileSought, TagFile, DiskPromptStyle, PathBuffer, PathBufferSize, PathRequiredSize)
# hwndParent : HWND -> "void*"
# DialogTitle : LPCSTR optional -> "char*"
# DiskName : LPCSTR optional -> "char*"
# PathToSource : LPCSTR optional -> "char*"
# FileSought : LPCSTR -> "char*"
# TagFile : LPCSTR optional -> "char*"
# DiskPromptStyle : DWORD -> "dword"
# PathBuffer : LPSTR optional, out -> "char*"
# PathBufferSize : DWORD -> "dword"
# PathRequiredSize : DWORD* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。