ホーム › Devices.DeviceAndDriverInstallation › SetupQueueDefaultCopyW
SetupQueueDefaultCopyW
関数INFの既定設定に従いコピー操作をキューに追加する(Unicode)。
シグネチャ
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
BOOL SetupQueueDefaultCopyW(
void* QueueHandle,
void* InfHandle,
LPCWSTR SourceRootPath, // optional
LPCWSTR SourceFilename,
LPCWSTR TargetFilename, // optional
DWORD CopyStyle
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| QueueHandle | void* | in | コピー操作を登録するファイルキューのハンドル。 |
| InfHandle | void* | in | ソースメディア情報を参照するINFファイルのハンドル。NULL可。 |
| SourceRootPath | LPCWSTR | inoptional | ソースファイルが存在するルートパス(Unicode)。 |
| SourceFilename | LPCWSTR | in | コピー元ファイル名のみを指定する(Unicode)。 |
| TargetFilename | LPCWSTR | inoptional | コピー先ファイル名。NULLならソース名を使用する。 |
| CopyStyle | DWORD | in | SP_COPY_*系のコピー動作フラグ。 |
戻り値の型: 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 <MarshalAs(UnmanagedType.Bool)> 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 // BOOLfunction 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 版の利用を推奨。const std = @import("std");
extern "setupapi" fn SetupQueueDefaultCopyW(
QueueHandle: ?*anyopaque, // void*
InfHandle: ?*anyopaque, // void*
SourceRootPath: [*c]const u16, // LPCWSTR optional
SourceFilename: [*c]const u16, // LPCWSTR
TargetFilename: [*c]const u16, // LPCWSTR optional
CopyStyle: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc SetupQueueDefaultCopyW(
QueueHandle: pointer, # void*
InfHandle: pointer, # void*
SourceRootPath: WideCString, # LPCWSTR optional
SourceFilename: WideCString, # LPCWSTR
TargetFilename: WideCString, # LPCWSTR optional
CopyStyle: uint32 # DWORD
): int32 {.importc: "SetupQueueDefaultCopyW", stdcall, dynlib: "SETUPAPI.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "setupapi");
extern(Windows)
int SetupQueueDefaultCopyW(
void* QueueHandle, // void*
void* InfHandle, // void*
const(wchar)* SourceRootPath, // LPCWSTR optional
const(wchar)* SourceFilename, // LPCWSTR
const(wchar)* TargetFilename, // LPCWSTR optional
uint CopyStyle // DWORD
);ccall((:SetupQueueDefaultCopyW, "SETUPAPI.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{Cvoid}, Cwstring, Cwstring, Cwstring, UInt32),
QueueHandle, InfHandle, SourceRootPath, SourceFilename, TargetFilename, CopyStyle)
# QueueHandle : void* -> Ptr{Cvoid}
# InfHandle : void* -> Ptr{Cvoid}
# SourceRootPath : LPCWSTR optional -> Cwstring
# SourceFilename : LPCWSTR -> Cwstring
# TargetFilename : LPCWSTR optional -> Cwstring
# CopyStyle : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
int32_t SetupQueueDefaultCopyW(
void* QueueHandle,
void* InfHandle,
const uint16_t* SourceRootPath,
const uint16_t* SourceFilename,
const uint16_t* TargetFilename,
uint32_t CopyStyle);
]]
local setupapi = ffi.load("setupapi")
-- setupapi.SetupQueueDefaultCopyW(QueueHandle, InfHandle, SourceRootPath, SourceFilename, TargetFilename, CopyStyle)
-- QueueHandle : void*
-- InfHandle : void*
-- SourceRootPath : LPCWSTR optional
-- SourceFilename : LPCWSTR
-- TargetFilename : LPCWSTR optional
-- CopyStyle : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('SETUPAPI.dll');
const SetupQueueDefaultCopyW = lib.func('__stdcall', 'SetupQueueDefaultCopyW', 'int32_t', ['void *', 'void *', 'str16', 'str16', 'str16', 'uint32_t']);
// SetupQueueDefaultCopyW(QueueHandle, InfHandle, SourceRootPath, SourceFilename, TargetFilename, CopyStyle)
// QueueHandle : void* -> 'void *'
// InfHandle : void* -> 'void *'
// SourceRootPath : LPCWSTR optional -> 'str16'
// SourceFilename : LPCWSTR -> 'str16'
// TargetFilename : LPCWSTR optional -> 'str16'
// CopyStyle : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("SETUPAPI.dll", {
SetupQueueDefaultCopyW: { parameters: ["pointer", "pointer", "buffer", "buffer", "buffer", "u32"], result: "i32" },
});
// lib.symbols.SetupQueueDefaultCopyW(QueueHandle, InfHandle, SourceRootPath, SourceFilename, TargetFilename, CopyStyle)
// QueueHandle : void* -> "pointer"
// InfHandle : void* -> "pointer"
// SourceRootPath : LPCWSTR optional -> "buffer"
// SourceFilename : LPCWSTR -> "buffer"
// TargetFilename : LPCWSTR optional -> "buffer"
// CopyStyle : DWORD -> "u32"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t SetupQueueDefaultCopyW(
void* QueueHandle,
void* InfHandle,
const uint16_t* SourceRootPath,
const uint16_t* SourceFilename,
const uint16_t* TargetFilename,
uint32_t CopyStyle);
C, "SETUPAPI.dll");
// $ffi->SetupQueueDefaultCopyW(QueueHandle, InfHandle, SourceRootPath, SourceFilename, TargetFilename, CopyStyle);
// QueueHandle : void*
// InfHandle : void*
// SourceRootPath : LPCWSTR optional
// SourceFilename : LPCWSTR
// TargetFilename : LPCWSTR 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.UNICODE_OPTIONS);
boolean SetupQueueDefaultCopyW(
Pointer QueueHandle, // void*
Pointer InfHandle, // void*
WString SourceRootPath, // LPCWSTR optional
WString SourceFilename, // LPCWSTR
WString TargetFilename, // LPCWSTR optional
int CopyStyle // DWORD
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("setupapi")]
lib LibSETUPAPI
fun SetupQueueDefaultCopyW = SetupQueueDefaultCopyW(
QueueHandle : Void*, # void*
InfHandle : Void*, # void*
SourceRootPath : UInt16*, # LPCWSTR optional
SourceFilename : UInt16*, # LPCWSTR
TargetFilename : UInt16*, # LPCWSTR 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 SetupQueueDefaultCopyWNative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Uint32);
typedef SetupQueueDefaultCopyWDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, int);
final SetupQueueDefaultCopyW = DynamicLibrary.open('SETUPAPI.dll')
.lookupFunction<SetupQueueDefaultCopyWNative, SetupQueueDefaultCopyWDart>('SetupQueueDefaultCopyW');
// QueueHandle : void* -> Pointer<Void>
// InfHandle : void* -> Pointer<Void>
// SourceRootPath : LPCWSTR optional -> Pointer<Utf16>
// SourceFilename : LPCWSTR -> Pointer<Utf16>
// TargetFilename : LPCWSTR optional -> Pointer<Utf16>
// CopyStyle : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SetupQueueDefaultCopyW"
c_SetupQueueDefaultCopyW :: Ptr () -> Ptr () -> CWString -> CWString -> CWString -> Word32 -> IO CInt
-- QueueHandle : void* -> Ptr ()
-- InfHandle : void* -> Ptr ()
-- SourceRootPath : LPCWSTR optional -> CWString
-- SourceFilename : LPCWSTR -> CWString
-- TargetFilename : LPCWSTR optional -> CWString
-- CopyStyle : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let setupqueuedefaultcopyw =
foreign "SetupQueueDefaultCopyW"
((ptr void) @-> (ptr void) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> uint32_t @-> returning int32_t)
(* QueueHandle : void* -> (ptr void) *)
(* InfHandle : void* -> (ptr void) *)
(* SourceRootPath : LPCWSTR optional -> (ptr uint16_t) *)
(* SourceFilename : LPCWSTR -> (ptr uint16_t) *)
(* TargetFilename : LPCWSTR optional -> (ptr uint16_t) *)
(* 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 ("SetupQueueDefaultCopyW" setup-queue-default-copy-w :convention :stdcall) :int32
(queue-handle :pointer) ; void*
(inf-handle :pointer) ; void*
(source-root-path (:string :encoding :utf-16le)) ; LPCWSTR optional
(source-filename (:string :encoding :utf-16le)) ; LPCWSTR
(target-filename (:string :encoding :utf-16le)) ; LPCWSTR optional
(copy-style :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SetupQueueDefaultCopyW = Win32::API::More->new('SETUPAPI',
'BOOL SetupQueueDefaultCopyW(LPVOID QueueHandle, LPVOID InfHandle, LPCWSTR SourceRootPath, LPCWSTR SourceFilename, LPCWSTR TargetFilename, DWORD CopyStyle)');
# my $ret = $SetupQueueDefaultCopyW->Call($QueueHandle, $InfHandle, $SourceRootPath, $SourceFilename, $TargetFilename, $CopyStyle);
# QueueHandle : void* -> LPVOID
# InfHandle : void* -> LPVOID
# SourceRootPath : LPCWSTR optional -> LPCWSTR
# SourceFilename : LPCWSTR -> LPCWSTR
# TargetFilename : LPCWSTR optional -> LPCWSTR
# CopyStyle : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f SetupQueueDefaultCopyA (ANSI版) — INFの既定設定に従いコピー操作をキューに追加する(ANSI)。