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

SetupQueueDefaultCopyW

関数
INFの既定設定に従いコピー操作をキューに追加する(Unicode)。
DLLSETUPAPI.dll文字セットUnicode (-W)呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

// SETUPAPI.dll  (Unicode / -W)
#include <windows.h>

BOOL SetupQueueDefaultCopyW(
    void* QueueHandle,
    void* InfHandle,
    LPCWSTR SourceRootPath,   // optional
    LPCWSTR SourceFilename,
    LPCWSTR TargetFilename,   // optional
    DWORD CopyStyle
);

パラメーター

名前方向
QueueHandlevoid*in
InfHandlevoid*in
SourceRootPathLPCWSTRinoptional
SourceFilenameLPCWSTRin
TargetFilenameLPCWSTRinoptional
CopyStyleDWORDin

戻り値の型: BOOL

各言語での呼び出し定義

// SETUPAPI.dll  (Unicode / -W)
#include <windows.h>

BOOL SetupQueueDefaultCopyW(
    void* QueueHandle,
    void* InfHandle,
    LPCWSTR SourceRootPath,   // optional
    LPCWSTR SourceFilename,
    LPCWSTR TargetFilename,   // optional
    DWORD CopyStyle
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool SetupQueueDefaultCopyW(
    IntPtr QueueHandle,   // void*
    IntPtr InfHandle,   // void*
    [MarshalAs(UnmanagedType.LPWStr)] string SourceRootPath,   // LPCWSTR optional
    [MarshalAs(UnmanagedType.LPWStr)] string SourceFilename,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string TargetFilename,   // LPCWSTR optional
    uint CopyStyle   // DWORD
);
<DllImport("SETUPAPI.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupQueueDefaultCopyW(
    QueueHandle As IntPtr,   ' void*
    InfHandle As IntPtr,   ' void*
    <MarshalAs(UnmanagedType.LPWStr)> SourceRootPath As String,   ' LPCWSTR optional
    <MarshalAs(UnmanagedType.LPWStr)> SourceFilename As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> TargetFilename As String,   ' LPCWSTR optional
    CopyStyle As UInteger   ' DWORD
) As Boolean
End Function
' QueueHandle : void*
' InfHandle : void*
' SourceRootPath : LPCWSTR optional
' SourceFilename : LPCWSTR
' TargetFilename : LPCWSTR optional
' CopyStyle : DWORD
Declare PtrSafe Function SetupQueueDefaultCopyW Lib "setupapi" ( _
    ByVal QueueHandle As LongPtr, _
    ByVal InfHandle As LongPtr, _
    ByVal SourceRootPath As LongPtr, _
    ByVal SourceFilename As LongPtr, _
    ByVal TargetFilename As LongPtr, _
    ByVal CopyStyle 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

SetupQueueDefaultCopyW = ctypes.windll.setupapi.SetupQueueDefaultCopyW
SetupQueueDefaultCopyW.restype = wintypes.BOOL
SetupQueueDefaultCopyW.argtypes = [
    ctypes.POINTER(None),  # QueueHandle : void*
    ctypes.POINTER(None),  # InfHandle : void*
    wintypes.LPCWSTR,  # SourceRootPath : LPCWSTR optional
    wintypes.LPCWSTR,  # SourceFilename : LPCWSTR
    wintypes.LPCWSTR,  # TargetFilename : LPCWSTR optional
    wintypes.DWORD,  # CopyStyle : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SETUPAPI.dll')
SetupQueueDefaultCopyW = Fiddle::Function.new(
  lib['SetupQueueDefaultCopyW'],
  [
    Fiddle::TYPE_VOIDP,  # QueueHandle : void*
    Fiddle::TYPE_VOIDP,  # InfHandle : void*
    Fiddle::TYPE_VOIDP,  # SourceRootPath : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # SourceFilename : LPCWSTR
    Fiddle::TYPE_VOIDP,  # TargetFilename : LPCWSTR optional
    -Fiddle::TYPE_INT,  # CopyStyle : DWORD
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "setupapi")]
extern "system" {
    fn SetupQueueDefaultCopyW(
        QueueHandle: *mut (),  // void*
        InfHandle: *mut (),  // void*
        SourceRootPath: *const u16,  // LPCWSTR optional
        SourceFilename: *const u16,  // LPCWSTR
        TargetFilename: *const u16,  // LPCWSTR optional
        CopyStyle: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool SetupQueueDefaultCopyW(IntPtr QueueHandle, IntPtr InfHandle, [MarshalAs(UnmanagedType.LPWStr)] string SourceRootPath, [MarshalAs(UnmanagedType.LPWStr)] string SourceFilename, [MarshalAs(UnmanagedType.LPWStr)] string TargetFilename, uint CopyStyle);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupQueueDefaultCopyW' -Namespace Win32 -PassThru
# $api::SetupQueueDefaultCopyW(QueueHandle, InfHandle, SourceRootPath, SourceFilename, TargetFilename, CopyStyle)
#uselib "SETUPAPI.dll"
#func global SetupQueueDefaultCopyW "SetupQueueDefaultCopyW" wptr, wptr, wptr, wptr, wptr, wptr
; SetupQueueDefaultCopyW QueueHandle, InfHandle, SourceRootPath, SourceFilename, TargetFilename, CopyStyle   ; 戻り値は stat
; QueueHandle : void* -> "wptr"
; InfHandle : void* -> "wptr"
; SourceRootPath : LPCWSTR optional -> "wptr"
; SourceFilename : LPCWSTR -> "wptr"
; TargetFilename : LPCWSTR optional -> "wptr"
; CopyStyle : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SETUPAPI.dll"
#cfunc global SetupQueueDefaultCopyW "SetupQueueDefaultCopyW" sptr, sptr, wstr, wstr, wstr, int
; res = SetupQueueDefaultCopyW(QueueHandle, InfHandle, SourceRootPath, SourceFilename, TargetFilename, CopyStyle)
; QueueHandle : void* -> "sptr"
; InfHandle : void* -> "sptr"
; SourceRootPath : LPCWSTR optional -> "wstr"
; SourceFilename : LPCWSTR -> "wstr"
; TargetFilename : LPCWSTR optional -> "wstr"
; CopyStyle : DWORD -> "int"
; BOOL SetupQueueDefaultCopyW(void* QueueHandle, void* InfHandle, LPCWSTR SourceRootPath, LPCWSTR SourceFilename, LPCWSTR TargetFilename, DWORD CopyStyle)
#uselib "SETUPAPI.dll"
#cfunc global SetupQueueDefaultCopyW "SetupQueueDefaultCopyW" intptr, intptr, wstr, wstr, wstr, int
; res = SetupQueueDefaultCopyW(QueueHandle, InfHandle, SourceRootPath, SourceFilename, TargetFilename, CopyStyle)
; QueueHandle : void* -> "intptr"
; InfHandle : void* -> "intptr"
; SourceRootPath : LPCWSTR optional -> "wstr"
; SourceFilename : LPCWSTR -> "wstr"
; TargetFilename : LPCWSTR optional -> "wstr"
; CopyStyle : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
	procSetupQueueDefaultCopyW = setupapi.NewProc("SetupQueueDefaultCopyW")
)

// QueueHandle (void*), InfHandle (void*), SourceRootPath (LPCWSTR optional), SourceFilename (LPCWSTR), TargetFilename (LPCWSTR optional), CopyStyle (DWORD)
r1, _, err := procSetupQueueDefaultCopyW.Call(
	uintptr(QueueHandle),
	uintptr(InfHandle),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(SourceRootPath))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(SourceFilename))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(TargetFilename))),
	uintptr(CopyStyle),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function SetupQueueDefaultCopyW(
  QueueHandle: Pointer;   // void*
  InfHandle: Pointer;   // void*
  SourceRootPath: PWideChar;   // LPCWSTR optional
  SourceFilename: PWideChar;   // LPCWSTR
  TargetFilename: PWideChar;   // LPCWSTR optional
  CopyStyle: DWORD   // DWORD
): BOOL; stdcall;
  external 'SETUPAPI.dll' name 'SetupQueueDefaultCopyW';
result := DllCall("SETUPAPI\SetupQueueDefaultCopyW"
    , "Ptr", QueueHandle   ; void*
    , "Ptr", InfHandle   ; void*
    , "WStr", SourceRootPath   ; LPCWSTR optional
    , "WStr", SourceFilename   ; LPCWSTR
    , "WStr", TargetFilename   ; LPCWSTR optional
    , "UInt", CopyStyle   ; DWORD
    , "Int")   ; return: BOOL
●SetupQueueDefaultCopyW(QueueHandle, InfHandle, SourceRootPath, SourceFilename, TargetFilename, CopyStyle) = DLL("SETUPAPI.dll", "bool SetupQueueDefaultCopyW(void*, void*, char*, char*, char*, dword)")
# 呼び出し: SetupQueueDefaultCopyW(QueueHandle, InfHandle, SourceRootPath, SourceFilename, TargetFilename, CopyStyle)
# QueueHandle : void* -> "void*"
# InfHandle : void* -> "void*"
# SourceRootPath : LPCWSTR optional -> "char*"
# SourceFilename : LPCWSTR -> "char*"
# TargetFilename : LPCWSTR optional -> "char*"
# CopyStyle : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。