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
InfHandlevoid*in
ListInfHandlevoid*inoptional
SectionLPCWSTRin
CopyStyleDWORDin

戻り値の型: 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 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 版の利用を推奨。