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ソースメディア情報を参照するINFファイルのハンドル。NULL可。
SourceRootPathLPCSTRinoptionalソースファイルが存在するルートパス(ANSI)。
SourceFilenameLPCSTRinコピー元ファイル名のみを指定する(ANSI)。
TargetFilenameLPCSTRinoptionalコピー先ファイル名。NULLならソース名を使用する。
CopyStyleDWORDinSP_COPY_*系のコピー動作フラグ。

戻り値の型: 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 <MarshalAs(UnmanagedType.Bool)> 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)。
const std = @import("std");

extern "setupapi" fn SetupQueueDefaultCopyA(
    QueueHandle: ?*anyopaque, // void*
    InfHandle: ?*anyopaque, // void*
    SourceRootPath: [*c]const u8, // LPCSTR optional
    SourceFilename: [*c]const u8, // LPCSTR
    TargetFilename: [*c]const u8, // LPCSTR optional
    CopyStyle: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;
proc SetupQueueDefaultCopyA(
    QueueHandle: pointer,  # void*
    InfHandle: pointer,  # void*
    SourceRootPath: cstring,  # LPCSTR optional
    SourceFilename: cstring,  # LPCSTR
    TargetFilename: cstring,  # LPCSTR optional
    CopyStyle: uint32  # DWORD
): int32 {.importc: "SetupQueueDefaultCopyA", stdcall, dynlib: "SETUPAPI.dll".}
pragma(lib, "setupapi");
extern(Windows)
int SetupQueueDefaultCopyA(
    void* QueueHandle,   // void*
    void* InfHandle,   // void*
    const(char)* SourceRootPath,   // LPCSTR optional
    const(char)* SourceFilename,   // LPCSTR
    const(char)* TargetFilename,   // LPCSTR optional
    uint CopyStyle   // DWORD
);
ccall((:SetupQueueDefaultCopyA, "SETUPAPI.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Ptr{Cvoid}, Cstring, Cstring, Cstring, UInt32),
      QueueHandle, InfHandle, SourceRootPath, SourceFilename, TargetFilename, CopyStyle)
# QueueHandle : void* -> Ptr{Cvoid}
# InfHandle : void* -> Ptr{Cvoid}
# SourceRootPath : LPCSTR optional -> Cstring
# SourceFilename : LPCSTR -> Cstring
# TargetFilename : LPCSTR optional -> Cstring
# CopyStyle : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t SetupQueueDefaultCopyA(
    void* QueueHandle,
    void* InfHandle,
    const char* SourceRootPath,
    const char* SourceFilename,
    const char* TargetFilename,
    uint32_t CopyStyle);
]]
local setupapi = ffi.load("setupapi")
-- setupapi.SetupQueueDefaultCopyA(QueueHandle, InfHandle, SourceRootPath, SourceFilename, TargetFilename, CopyStyle)
-- QueueHandle : void*
-- InfHandle : void*
-- SourceRootPath : LPCSTR optional
-- SourceFilename : LPCSTR
-- TargetFilename : LPCSTR optional
-- CopyStyle : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('SETUPAPI.dll');
const SetupQueueDefaultCopyA = lib.func('__stdcall', 'SetupQueueDefaultCopyA', 'int32_t', ['void *', 'void *', 'str', 'str', 'str', 'uint32_t']);
// SetupQueueDefaultCopyA(QueueHandle, InfHandle, SourceRootPath, SourceFilename, TargetFilename, CopyStyle)
// QueueHandle : void* -> 'void *'
// InfHandle : void* -> 'void *'
// SourceRootPath : LPCSTR optional -> 'str'
// SourceFilename : LPCSTR -> 'str'
// TargetFilename : LPCSTR optional -> 'str'
// CopyStyle : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("SETUPAPI.dll", {
  SetupQueueDefaultCopyA: { parameters: ["pointer", "pointer", "buffer", "buffer", "buffer", "u32"], result: "i32" },
});
// lib.symbols.SetupQueueDefaultCopyA(QueueHandle, InfHandle, SourceRootPath, SourceFilename, TargetFilename, CopyStyle)
// QueueHandle : void* -> "pointer"
// InfHandle : void* -> "pointer"
// SourceRootPath : LPCSTR optional -> "buffer"
// SourceFilename : LPCSTR -> "buffer"
// TargetFilename : LPCSTR optional -> "buffer"
// CopyStyle : DWORD -> "u32"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t SetupQueueDefaultCopyA(
    void* QueueHandle,
    void* InfHandle,
    const char* SourceRootPath,
    const char* SourceFilename,
    const char* TargetFilename,
    uint32_t CopyStyle);
C, "SETUPAPI.dll");
// $ffi->SetupQueueDefaultCopyA(QueueHandle, InfHandle, SourceRootPath, SourceFilename, TargetFilename, CopyStyle);
// QueueHandle : void*
// InfHandle : void*
// SourceRootPath : LPCSTR optional
// SourceFilename : LPCSTR
// TargetFilename : LPCSTR optional
// CopyStyle : DWORD
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Setupapi extends StdCallLibrary {
    Setupapi INSTANCE = Native.load("setupapi", Setupapi.class, W32APIOptions.ASCII_OPTIONS);
    boolean SetupQueueDefaultCopyA(
        Pointer QueueHandle,   // void*
        Pointer InfHandle,   // void*
        String SourceRootPath,   // LPCSTR optional
        String SourceFilename,   // LPCSTR
        String TargetFilename,   // LPCSTR optional
        int CopyStyle   // DWORD
    );
}
@[Link("setupapi")]
lib LibSETUPAPI
  fun SetupQueueDefaultCopyA = SetupQueueDefaultCopyA(
    QueueHandle : Void*,   # void*
    InfHandle : Void*,   # void*
    SourceRootPath : UInt8*,   # LPCSTR optional
    SourceFilename : UInt8*,   # LPCSTR
    TargetFilename : UInt8*,   # LPCSTR optional
    CopyStyle : UInt32   # DWORD
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef SetupQueueDefaultCopyANative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, Uint32);
typedef SetupQueueDefaultCopyADart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, int);
final SetupQueueDefaultCopyA = DynamicLibrary.open('SETUPAPI.dll')
    .lookupFunction<SetupQueueDefaultCopyANative, SetupQueueDefaultCopyADart>('SetupQueueDefaultCopyA');
// QueueHandle : void* -> Pointer<Void>
// InfHandle : void* -> Pointer<Void>
// SourceRootPath : LPCSTR optional -> Pointer<Utf8>
// SourceFilename : LPCSTR -> Pointer<Utf8>
// TargetFilename : LPCSTR optional -> Pointer<Utf8>
// CopyStyle : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
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';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "SetupQueueDefaultCopyA"
  c_SetupQueueDefaultCopyA :: Ptr () -> Ptr () -> CString -> CString -> CString -> Word32 -> IO CInt
-- QueueHandle : void* -> Ptr ()
-- InfHandle : void* -> Ptr ()
-- SourceRootPath : LPCSTR optional -> CString
-- SourceFilename : LPCSTR -> CString
-- TargetFilename : LPCSTR optional -> CString
-- CopyStyle : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let setupqueuedefaultcopya =
  foreign "SetupQueueDefaultCopyA"
    ((ptr void) @-> (ptr void) @-> string @-> string @-> string @-> uint32_t @-> returning int32_t)
(* QueueHandle : void* -> (ptr void) *)
(* InfHandle : void* -> (ptr void) *)
(* SourceRootPath : LPCSTR optional -> string *)
(* SourceFilename : LPCSTR -> string *)
(* TargetFilename : LPCSTR optional -> string *)
(* CopyStyle : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library setupapi (t "SETUPAPI.dll"))
(cffi:use-foreign-library setupapi)

(cffi:defcfun ("SetupQueueDefaultCopyA" setup-queue-default-copy-a :convention :stdcall) :int32
  (queue-handle :pointer)   ; void*
  (inf-handle :pointer)   ; void*
  (source-root-path :string)   ; LPCSTR optional
  (source-filename :string)   ; LPCSTR
  (target-filename :string)   ; LPCSTR optional
  (copy-style :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SetupQueueDefaultCopyA = Win32::API::More->new('SETUPAPI',
    'BOOL SetupQueueDefaultCopyA(LPVOID QueueHandle, LPVOID InfHandle, LPCSTR SourceRootPath, LPCSTR SourceFilename, LPCSTR TargetFilename, DWORD CopyStyle)');
# my $ret = $SetupQueueDefaultCopyA->Call($QueueHandle, $InfHandle, $SourceRootPath, $SourceFilename, $TargetFilename, $CopyStyle);
# QueueHandle : void* -> LPVOID
# InfHandle : void* -> LPVOID
# SourceRootPath : LPCSTR optional -> LPCSTR
# SourceFilename : LPCSTR -> LPCSTR
# TargetFilename : LPCSTR optional -> LPCSTR
# CopyStyle : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

文字セット違い