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

SetupQueueDefaultCopyA

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

シグネチャ

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

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

パラメーター

名前方向
QueueHandlevoid*in
InfHandlevoid*in
SourceRootPathLPCSTRinoptional
SourceFilenameLPCSTRin
TargetFilenameLPCSTRinoptional
CopyStyleDWORDin

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL SetupQueueDefaultCopyA(
    void* QueueHandle,
    void* InfHandle,
    LPCSTR SourceRootPath,   // optional
    LPCSTR SourceFilename,
    LPCSTR TargetFilename,   // optional
    DWORD CopyStyle
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool SetupQueueDefaultCopyA(
    IntPtr QueueHandle,   // void*
    IntPtr InfHandle,   // void*
    [MarshalAs(UnmanagedType.LPStr)] string SourceRootPath,   // LPCSTR optional
    [MarshalAs(UnmanagedType.LPStr)] string SourceFilename,   // LPCSTR
    [MarshalAs(UnmanagedType.LPStr)] string TargetFilename,   // LPCSTR optional
    uint CopyStyle   // DWORD
);
<DllImport("SETUPAPI.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupQueueDefaultCopyA(
    QueueHandle As IntPtr,   ' void*
    InfHandle As IntPtr,   ' void*
    <MarshalAs(UnmanagedType.LPStr)> SourceRootPath As String,   ' LPCSTR optional
    <MarshalAs(UnmanagedType.LPStr)> SourceFilename As String,   ' LPCSTR
    <MarshalAs(UnmanagedType.LPStr)> TargetFilename As String,   ' LPCSTR optional
    CopyStyle As UInteger   ' DWORD
) As Boolean
End Function
' QueueHandle : void*
' InfHandle : void*
' SourceRootPath : LPCSTR optional
' SourceFilename : LPCSTR
' TargetFilename : LPCSTR optional
' CopyStyle : DWORD
Declare PtrSafe Function SetupQueueDefaultCopyA Lib "setupapi" ( _
    ByVal QueueHandle As LongPtr, _
    ByVal InfHandle As LongPtr, _
    ByVal SourceRootPath As String, _
    ByVal SourceFilename As String, _
    ByVal TargetFilename As String, _
    ByVal CopyStyle As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SetupQueueDefaultCopyA = ctypes.windll.setupapi.SetupQueueDefaultCopyA
SetupQueueDefaultCopyA.restype = wintypes.BOOL
SetupQueueDefaultCopyA.argtypes = [
    ctypes.POINTER(None),  # QueueHandle : void*
    ctypes.POINTER(None),  # InfHandle : void*
    wintypes.LPCSTR,  # SourceRootPath : LPCSTR optional
    wintypes.LPCSTR,  # SourceFilename : LPCSTR
    wintypes.LPCSTR,  # TargetFilename : LPCSTR 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')
SetupQueueDefaultCopyA = Fiddle::Function.new(
  lib['SetupQueueDefaultCopyA'],
  [
    Fiddle::TYPE_VOIDP,  # QueueHandle : void*
    Fiddle::TYPE_VOIDP,  # InfHandle : void*
    Fiddle::TYPE_VOIDP,  # SourceRootPath : LPCSTR optional
    Fiddle::TYPE_VOIDP,  # SourceFilename : LPCSTR
    Fiddle::TYPE_VOIDP,  # TargetFilename : LPCSTR optional
    -Fiddle::TYPE_INT,  # CopyStyle : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "setupapi")]
extern "system" {
    fn SetupQueueDefaultCopyA(
        QueueHandle: *mut (),  // void*
        InfHandle: *mut (),  // void*
        SourceRootPath: *const u8,  // LPCSTR optional
        SourceFilename: *const u8,  // LPCSTR
        TargetFilename: *const u8,  // LPCSTR 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.Ansi, SetLastError = true)]
public static extern bool SetupQueueDefaultCopyA(IntPtr QueueHandle, IntPtr InfHandle, [MarshalAs(UnmanagedType.LPStr)] string SourceRootPath, [MarshalAs(UnmanagedType.LPStr)] string SourceFilename, [MarshalAs(UnmanagedType.LPStr)] string TargetFilename, uint CopyStyle);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupQueueDefaultCopyA' -Namespace Win32 -PassThru
# $api::SetupQueueDefaultCopyA(QueueHandle, InfHandle, SourceRootPath, SourceFilename, TargetFilename, CopyStyle)
#uselib "SETUPAPI.dll"
#func global SetupQueueDefaultCopyA "SetupQueueDefaultCopyA" sptr, sptr, sptr, sptr, sptr, sptr
; SetupQueueDefaultCopyA QueueHandle, InfHandle, SourceRootPath, SourceFilename, TargetFilename, CopyStyle   ; 戻り値は stat
; QueueHandle : void* -> "sptr"
; InfHandle : void* -> "sptr"
; SourceRootPath : LPCSTR optional -> "sptr"
; SourceFilename : LPCSTR -> "sptr"
; TargetFilename : LPCSTR optional -> "sptr"
; CopyStyle : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SETUPAPI.dll"
#cfunc global SetupQueueDefaultCopyA "SetupQueueDefaultCopyA" sptr, sptr, str, str, str, int
; res = SetupQueueDefaultCopyA(QueueHandle, InfHandle, SourceRootPath, SourceFilename, TargetFilename, CopyStyle)
; QueueHandle : void* -> "sptr"
; InfHandle : void* -> "sptr"
; SourceRootPath : LPCSTR optional -> "str"
; SourceFilename : LPCSTR -> "str"
; TargetFilename : LPCSTR optional -> "str"
; CopyStyle : DWORD -> "int"
; BOOL SetupQueueDefaultCopyA(void* QueueHandle, void* InfHandle, LPCSTR SourceRootPath, LPCSTR SourceFilename, LPCSTR TargetFilename, DWORD CopyStyle)
#uselib "SETUPAPI.dll"
#cfunc global SetupQueueDefaultCopyA "SetupQueueDefaultCopyA" intptr, intptr, str, str, str, int
; res = SetupQueueDefaultCopyA(QueueHandle, InfHandle, SourceRootPath, SourceFilename, TargetFilename, CopyStyle)
; QueueHandle : void* -> "intptr"
; InfHandle : void* -> "intptr"
; SourceRootPath : LPCSTR optional -> "str"
; SourceFilename : LPCSTR -> "str"
; TargetFilename : LPCSTR optional -> "str"
; CopyStyle : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
	procSetupQueueDefaultCopyA = setupapi.NewProc("SetupQueueDefaultCopyA")
)

// QueueHandle (void*), InfHandle (void*), SourceRootPath (LPCSTR optional), SourceFilename (LPCSTR), TargetFilename (LPCSTR optional), CopyStyle (DWORD)
r1, _, err := procSetupQueueDefaultCopyA.Call(
	uintptr(QueueHandle),
	uintptr(InfHandle),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(SourceRootPath))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(SourceFilename))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(TargetFilename))),
	uintptr(CopyStyle),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function SetupQueueDefaultCopyA(
  QueueHandle: Pointer;   // void*
  InfHandle: Pointer;   // void*
  SourceRootPath: PAnsiChar;   // LPCSTR optional
  SourceFilename: PAnsiChar;   // LPCSTR
  TargetFilename: PAnsiChar;   // LPCSTR optional
  CopyStyle: DWORD   // DWORD
): BOOL; stdcall;
  external 'SETUPAPI.dll' name 'SetupQueueDefaultCopyA';
result := DllCall("SETUPAPI\SetupQueueDefaultCopyA"
    , "Ptr", QueueHandle   ; void*
    , "Ptr", InfHandle   ; void*
    , "AStr", SourceRootPath   ; LPCSTR optional
    , "AStr", SourceFilename   ; LPCSTR
    , "AStr", TargetFilename   ; LPCSTR optional
    , "UInt", CopyStyle   ; DWORD
    , "Int")   ; return: BOOL
●SetupQueueDefaultCopyA(QueueHandle, InfHandle, SourceRootPath, SourceFilename, TargetFilename, CopyStyle) = DLL("SETUPAPI.dll", "bool SetupQueueDefaultCopyA(void*, void*, char*, char*, char*, dword)")
# 呼び出し: SetupQueueDefaultCopyA(QueueHandle, InfHandle, SourceRootPath, SourceFilename, TargetFilename, CopyStyle)
# QueueHandle : void* -> "void*"
# InfHandle : void* -> "void*"
# SourceRootPath : LPCSTR optional -> "char*"
# SourceFilename : LPCSTR -> "char*"
# TargetFilename : LPCSTR optional -> "char*"
# CopyStyle : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。