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

SetupQueueCopySectionW

関数
INFセクションのファイル群をコピー操作としてキューに追加する(Unicode)。
DLLSETUPAPI.dll文字セットUnicode (-W)呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

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

BOOL SetupQueueCopySectionW(
    void* QueueHandle,
    LPCWSTR SourceRootPath,   // optional
    void* InfHandle,
    void* ListInfHandle,   // optional
    LPCWSTR Section,
    DWORD CopyStyle
);

パラメーター

名前方向説明
QueueHandlevoid*inコピー操作を登録するファイルキューのハンドル。
SourceRootPathLPCWSTRinoptionalソースファイルのルートパス(Unicode)。
InfHandlevoid*inコピーするファイルを記述したINFファイルのハンドル。
ListInfHandlevoid*inoptionalソースメディア情報を持つレイアウトINFのハンドル。NULL可。
SectionLPCWSTRinコピー対象を列挙したINFのセクション名(Unicode)。
CopyStyleDWORDinSP_COPY_*系のコピー動作フラグ。

戻り値の型: BOOL

各言語での呼び出し定義

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

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

SetupQueueCopySectionW = ctypes.windll.setupapi.SetupQueueCopySectionW
SetupQueueCopySectionW.restype = wintypes.BOOL
SetupQueueCopySectionW.argtypes = [
    ctypes.POINTER(None),  # QueueHandle : void*
    wintypes.LPCWSTR,  # SourceRootPath : LPCWSTR optional
    ctypes.POINTER(None),  # InfHandle : void*
    ctypes.POINTER(None),  # ListInfHandle : void* optional
    wintypes.LPCWSTR,  # Section : LPCWSTR
    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')
SetupQueueCopySectionW = Fiddle::Function.new(
  lib['SetupQueueCopySectionW'],
  [
    Fiddle::TYPE_VOIDP,  # QueueHandle : void*
    Fiddle::TYPE_VOIDP,  # SourceRootPath : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # InfHandle : void*
    Fiddle::TYPE_VOIDP,  # ListInfHandle : void* optional
    Fiddle::TYPE_VOIDP,  # Section : LPCWSTR
    -Fiddle::TYPE_INT,  # CopyStyle : DWORD
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "setupapi")]
extern "system" {
    fn SetupQueueCopySectionW(
        QueueHandle: *mut (),  // void*
        SourceRootPath: *const u16,  // LPCWSTR optional
        InfHandle: *mut (),  // void*
        ListInfHandle: *mut (),  // void* optional
        Section: *const u16,  // LPCWSTR
        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 SetupQueueCopySectionW(IntPtr QueueHandle, [MarshalAs(UnmanagedType.LPWStr)] string SourceRootPath, IntPtr InfHandle, IntPtr ListInfHandle, [MarshalAs(UnmanagedType.LPWStr)] string Section, uint CopyStyle);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupQueueCopySectionW' -Namespace Win32 -PassThru
# $api::SetupQueueCopySectionW(QueueHandle, SourceRootPath, InfHandle, ListInfHandle, Section, CopyStyle)
#uselib "SETUPAPI.dll"
#func global SetupQueueCopySectionW "SetupQueueCopySectionW" wptr, wptr, wptr, wptr, wptr, wptr
; SetupQueueCopySectionW QueueHandle, SourceRootPath, InfHandle, ListInfHandle, Section, CopyStyle   ; 戻り値は stat
; QueueHandle : void* -> "wptr"
; SourceRootPath : LPCWSTR optional -> "wptr"
; InfHandle : void* -> "wptr"
; ListInfHandle : void* optional -> "wptr"
; Section : LPCWSTR -> "wptr"
; CopyStyle : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SETUPAPI.dll"
#cfunc global SetupQueueCopySectionW "SetupQueueCopySectionW" sptr, wstr, sptr, sptr, wstr, int
; res = SetupQueueCopySectionW(QueueHandle, SourceRootPath, InfHandle, ListInfHandle, Section, CopyStyle)
; QueueHandle : void* -> "sptr"
; SourceRootPath : LPCWSTR optional -> "wstr"
; InfHandle : void* -> "sptr"
; ListInfHandle : void* optional -> "sptr"
; Section : LPCWSTR -> "wstr"
; CopyStyle : DWORD -> "int"
; BOOL SetupQueueCopySectionW(void* QueueHandle, LPCWSTR SourceRootPath, void* InfHandle, void* ListInfHandle, LPCWSTR Section, DWORD CopyStyle)
#uselib "SETUPAPI.dll"
#cfunc global SetupQueueCopySectionW "SetupQueueCopySectionW" intptr, wstr, intptr, intptr, wstr, int
; res = SetupQueueCopySectionW(QueueHandle, SourceRootPath, InfHandle, ListInfHandle, Section, CopyStyle)
; QueueHandle : void* -> "intptr"
; SourceRootPath : LPCWSTR optional -> "wstr"
; InfHandle : void* -> "intptr"
; ListInfHandle : void* optional -> "intptr"
; Section : LPCWSTR -> "wstr"
; CopyStyle : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
	procSetupQueueCopySectionW = setupapi.NewProc("SetupQueueCopySectionW")
)

// QueueHandle (void*), SourceRootPath (LPCWSTR optional), InfHandle (void*), ListInfHandle (void* optional), Section (LPCWSTR), CopyStyle (DWORD)
r1, _, err := procSetupQueueCopySectionW.Call(
	uintptr(QueueHandle),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(SourceRootPath))),
	uintptr(InfHandle),
	uintptr(ListInfHandle),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(Section))),
	uintptr(CopyStyle),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function SetupQueueCopySectionW(
  QueueHandle: Pointer;   // void*
  SourceRootPath: PWideChar;   // LPCWSTR optional
  InfHandle: Pointer;   // void*
  ListInfHandle: Pointer;   // void* optional
  Section: PWideChar;   // LPCWSTR
  CopyStyle: DWORD   // DWORD
): BOOL; stdcall;
  external 'SETUPAPI.dll' name 'SetupQueueCopySectionW';
result := DllCall("SETUPAPI\SetupQueueCopySectionW"
    , "Ptr", QueueHandle   ; void*
    , "WStr", SourceRootPath   ; LPCWSTR optional
    , "Ptr", InfHandle   ; void*
    , "Ptr", ListInfHandle   ; void* optional
    , "WStr", Section   ; LPCWSTR
    , "UInt", CopyStyle   ; DWORD
    , "Int")   ; return: BOOL
●SetupQueueCopySectionW(QueueHandle, SourceRootPath, InfHandle, ListInfHandle, Section, CopyStyle) = DLL("SETUPAPI.dll", "bool SetupQueueCopySectionW(void*, char*, void*, void*, char*, dword)")
# 呼び出し: SetupQueueCopySectionW(QueueHandle, SourceRootPath, InfHandle, ListInfHandle, Section, CopyStyle)
# QueueHandle : void* -> "void*"
# SourceRootPath : LPCWSTR optional -> "char*"
# InfHandle : void* -> "void*"
# ListInfHandle : void* optional -> "void*"
# Section : LPCWSTR -> "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 SetupQueueCopySectionW(
    QueueHandle: ?*anyopaque, // void*
    SourceRootPath: [*c]const u16, // LPCWSTR optional
    InfHandle: ?*anyopaque, // void*
    ListInfHandle: ?*anyopaque, // void* optional
    Section: [*c]const u16, // LPCWSTR
    CopyStyle: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。
proc SetupQueueCopySectionW(
    QueueHandle: pointer,  # void*
    SourceRootPath: WideCString,  # LPCWSTR optional
    InfHandle: pointer,  # void*
    ListInfHandle: pointer,  # void* optional
    Section: WideCString,  # LPCWSTR
    CopyStyle: uint32  # DWORD
): int32 {.importc: "SetupQueueCopySectionW", stdcall, dynlib: "SETUPAPI.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。
pragma(lib, "setupapi");
extern(Windows)
int SetupQueueCopySectionW(
    void* QueueHandle,   // void*
    const(wchar)* SourceRootPath,   // LPCWSTR optional
    void* InfHandle,   // void*
    void* ListInfHandle,   // void* optional
    const(wchar)* Section,   // LPCWSTR
    uint CopyStyle   // DWORD
);
ccall((:SetupQueueCopySectionW, "SETUPAPI.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Cwstring, Ptr{Cvoid}, Ptr{Cvoid}, Cwstring, UInt32),
      QueueHandle, SourceRootPath, InfHandle, ListInfHandle, Section, CopyStyle)
# QueueHandle : void* -> Ptr{Cvoid}
# SourceRootPath : LPCWSTR optional -> Cwstring
# InfHandle : void* -> Ptr{Cvoid}
# ListInfHandle : void* optional -> Ptr{Cvoid}
# Section : LPCWSTR -> Cwstring
# CopyStyle : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。
local ffi = require("ffi")
ffi.cdef[[
int32_t SetupQueueCopySectionW(
    void* QueueHandle,
    const uint16_t* SourceRootPath,
    void* InfHandle,
    void* ListInfHandle,
    const uint16_t* Section,
    uint32_t CopyStyle);
]]
local setupapi = ffi.load("setupapi")
-- setupapi.SetupQueueCopySectionW(QueueHandle, SourceRootPath, InfHandle, ListInfHandle, Section, CopyStyle)
-- QueueHandle : void*
-- SourceRootPath : LPCWSTR optional
-- InfHandle : void*
-- ListInfHandle : void* optional
-- Section : LPCWSTR
-- 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 SetupQueueCopySectionW = lib.func('__stdcall', 'SetupQueueCopySectionW', 'int32_t', ['void *', 'str16', 'void *', 'void *', 'str16', 'uint32_t']);
// SetupQueueCopySectionW(QueueHandle, SourceRootPath, InfHandle, ListInfHandle, Section, CopyStyle)
// QueueHandle : void* -> 'void *'
// SourceRootPath : LPCWSTR optional -> 'str16'
// InfHandle : void* -> 'void *'
// ListInfHandle : void* optional -> 'void *'
// Section : LPCWSTR -> 'str16'
// CopyStyle : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("SETUPAPI.dll", {
  SetupQueueCopySectionW: { parameters: ["pointer", "buffer", "pointer", "pointer", "buffer", "u32"], result: "i32" },
});
// lib.symbols.SetupQueueCopySectionW(QueueHandle, SourceRootPath, InfHandle, ListInfHandle, Section, CopyStyle)
// QueueHandle : void* -> "pointer"
// SourceRootPath : LPCWSTR optional -> "buffer"
// InfHandle : void* -> "pointer"
// ListInfHandle : void* optional -> "pointer"
// Section : LPCWSTR -> "buffer"
// CopyStyle : DWORD -> "u32"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t SetupQueueCopySectionW(
    void* QueueHandle,
    const uint16_t* SourceRootPath,
    void* InfHandle,
    void* ListInfHandle,
    const uint16_t* Section,
    uint32_t CopyStyle);
C, "SETUPAPI.dll");
// $ffi->SetupQueueCopySectionW(QueueHandle, SourceRootPath, InfHandle, ListInfHandle, Section, CopyStyle);
// QueueHandle : void*
// SourceRootPath : LPCWSTR optional
// InfHandle : void*
// ListInfHandle : void* optional
// Section : LPCWSTR
// 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 SetupQueueCopySectionW(
        Pointer QueueHandle,   // void*
        WString SourceRootPath,   // LPCWSTR optional
        Pointer InfHandle,   // void*
        Pointer ListInfHandle,   // void* optional
        WString Section,   // LPCWSTR
        int CopyStyle   // DWORD
    );
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。
@[Link("setupapi")]
lib LibSETUPAPI
  fun SetupQueueCopySectionW = SetupQueueCopySectionW(
    QueueHandle : Void*,   # void*
    SourceRootPath : UInt16*,   # LPCWSTR optional
    InfHandle : Void*,   # void*
    ListInfHandle : Void*,   # void* optional
    Section : UInt16*,   # LPCWSTR
    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 SetupQueueCopySectionWNative = Int32 Function(Pointer<Void>, Pointer<Utf16>, Pointer<Void>, Pointer<Void>, Pointer<Utf16>, Uint32);
typedef SetupQueueCopySectionWDart = int Function(Pointer<Void>, Pointer<Utf16>, Pointer<Void>, Pointer<Void>, Pointer<Utf16>, int);
final SetupQueueCopySectionW = DynamicLibrary.open('SETUPAPI.dll')
    .lookupFunction<SetupQueueCopySectionWNative, SetupQueueCopySectionWDart>('SetupQueueCopySectionW');
// QueueHandle : void* -> Pointer<Void>
// SourceRootPath : LPCWSTR optional -> Pointer<Utf16>
// InfHandle : void* -> Pointer<Void>
// ListInfHandle : void* optional -> Pointer<Void>
// Section : LPCWSTR -> Pointer<Utf16>
// CopyStyle : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function SetupQueueCopySectionW(
  QueueHandle: Pointer;   // void*
  SourceRootPath: PWideChar;   // LPCWSTR optional
  InfHandle: Pointer;   // void*
  ListInfHandle: Pointer;   // void* optional
  Section: PWideChar;   // LPCWSTR
  CopyStyle: DWORD   // DWORD
): BOOL; stdcall;
  external 'SETUPAPI.dll' name 'SetupQueueCopySectionW';
import Foreign
import Foreign.C.Types
import Foreign.C.String

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

let setupqueuecopysectionw =
  foreign "SetupQueueCopySectionW"
    ((ptr void) @-> (ptr uint16_t) @-> (ptr void) @-> (ptr void) @-> (ptr uint16_t) @-> uint32_t @-> returning int32_t)
(* QueueHandle : void* -> (ptr void) *)
(* SourceRootPath : LPCWSTR optional -> (ptr uint16_t) *)
(* InfHandle : void* -> (ptr void) *)
(* ListInfHandle : void* optional -> (ptr void) *)
(* Section : LPCWSTR -> (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 ("SetupQueueCopySectionW" setup-queue-copy-section-w :convention :stdcall) :int32
  (queue-handle :pointer)   ; void*
  (source-root-path (:string :encoding :utf-16le))   ; LPCWSTR optional
  (inf-handle :pointer)   ; void*
  (list-inf-handle :pointer)   ; void* optional
  (section (:string :encoding :utf-16le))   ; LPCWSTR
  (copy-style :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SetupQueueCopySectionW = Win32::API::More->new('SETUPAPI',
    'BOOL SetupQueueCopySectionW(LPVOID QueueHandle, LPCWSTR SourceRootPath, LPVOID InfHandle, LPVOID ListInfHandle, LPCWSTR Section, DWORD CopyStyle)');
# my $ret = $SetupQueueCopySectionW->Call($QueueHandle, $SourceRootPath, $InfHandle, $ListInfHandle, $Section, $CopyStyle);
# QueueHandle : void* -> LPVOID
# SourceRootPath : LPCWSTR optional -> LPCWSTR
# InfHandle : void* -> LPVOID
# ListInfHandle : void* optional -> LPVOID
# Section : LPCWSTR -> LPCWSTR
# CopyStyle : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。

関連項目

文字セット違い