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

SetupQueueCopySectionA

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

シグネチャ

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

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

パラメーター

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

戻り値の型: BOOL

各言語での呼び出し定義

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

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

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

var (
	setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
	procSetupQueueCopySectionA = setupapi.NewProc("SetupQueueCopySectionA")
)

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

extern "setupapi" fn SetupQueueCopySectionA(
    QueueHandle: ?*anyopaque, // void*
    SourceRootPath: [*c]const u8, // LPCSTR optional
    InfHandle: ?*anyopaque, // void*
    ListInfHandle: ?*anyopaque, // void* optional
    Section: [*c]const u8, // LPCSTR
    CopyStyle: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;
proc SetupQueueCopySectionA(
    QueueHandle: pointer,  # void*
    SourceRootPath: cstring,  # LPCSTR optional
    InfHandle: pointer,  # void*
    ListInfHandle: pointer,  # void* optional
    Section: cstring,  # LPCSTR
    CopyStyle: uint32  # DWORD
): int32 {.importc: "SetupQueueCopySectionA", stdcall, dynlib: "SETUPAPI.dll".}
pragma(lib, "setupapi");
extern(Windows)
int SetupQueueCopySectionA(
    void* QueueHandle,   // void*
    const(char)* SourceRootPath,   // LPCSTR optional
    void* InfHandle,   // void*
    void* ListInfHandle,   // void* optional
    const(char)* Section,   // LPCSTR
    uint CopyStyle   // DWORD
);
ccall((:SetupQueueCopySectionA, "SETUPAPI.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Cstring, Ptr{Cvoid}, Ptr{Cvoid}, Cstring, UInt32),
      QueueHandle, SourceRootPath, InfHandle, ListInfHandle, Section, CopyStyle)
# QueueHandle : void* -> Ptr{Cvoid}
# SourceRootPath : LPCSTR optional -> Cstring
# InfHandle : void* -> Ptr{Cvoid}
# ListInfHandle : void* optional -> Ptr{Cvoid}
# Section : LPCSTR -> Cstring
# CopyStyle : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t SetupQueueCopySectionA(
    void* QueueHandle,
    const char* SourceRootPath,
    void* InfHandle,
    void* ListInfHandle,
    const char* Section,
    uint32_t CopyStyle);
]]
local setupapi = ffi.load("setupapi")
-- setupapi.SetupQueueCopySectionA(QueueHandle, SourceRootPath, InfHandle, ListInfHandle, Section, CopyStyle)
-- QueueHandle : void*
-- SourceRootPath : LPCSTR optional
-- InfHandle : void*
-- ListInfHandle : void* optional
-- Section : LPCSTR
-- CopyStyle : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('SETUPAPI.dll');
const SetupQueueCopySectionA = lib.func('__stdcall', 'SetupQueueCopySectionA', 'int32_t', ['void *', 'str', 'void *', 'void *', 'str', 'uint32_t']);
// SetupQueueCopySectionA(QueueHandle, SourceRootPath, InfHandle, ListInfHandle, Section, CopyStyle)
// QueueHandle : void* -> 'void *'
// SourceRootPath : LPCSTR optional -> 'str'
// InfHandle : void* -> 'void *'
// ListInfHandle : void* optional -> 'void *'
// Section : LPCSTR -> 'str'
// CopyStyle : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("SETUPAPI.dll", {
  SetupQueueCopySectionA: { parameters: ["pointer", "buffer", "pointer", "pointer", "buffer", "u32"], result: "i32" },
});
// lib.symbols.SetupQueueCopySectionA(QueueHandle, SourceRootPath, InfHandle, ListInfHandle, Section, CopyStyle)
// QueueHandle : void* -> "pointer"
// SourceRootPath : LPCSTR optional -> "buffer"
// InfHandle : void* -> "pointer"
// ListInfHandle : void* optional -> "pointer"
// Section : LPCSTR -> "buffer"
// CopyStyle : DWORD -> "u32"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t SetupQueueCopySectionA(
    void* QueueHandle,
    const char* SourceRootPath,
    void* InfHandle,
    void* ListInfHandle,
    const char* Section,
    uint32_t CopyStyle);
C, "SETUPAPI.dll");
// $ffi->SetupQueueCopySectionA(QueueHandle, SourceRootPath, InfHandle, ListInfHandle, Section, CopyStyle);
// QueueHandle : void*
// SourceRootPath : LPCSTR optional
// InfHandle : void*
// ListInfHandle : void* optional
// Section : LPCSTR
// 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 SetupQueueCopySectionA(
        Pointer QueueHandle,   // void*
        String SourceRootPath,   // LPCSTR optional
        Pointer InfHandle,   // void*
        Pointer ListInfHandle,   // void* optional
        String Section,   // LPCSTR
        int CopyStyle   // DWORD
    );
}
@[Link("setupapi")]
lib LibSETUPAPI
  fun SetupQueueCopySectionA = SetupQueueCopySectionA(
    QueueHandle : Void*,   # void*
    SourceRootPath : UInt8*,   # LPCSTR optional
    InfHandle : Void*,   # void*
    ListInfHandle : Void*,   # void* optional
    Section : UInt8*,   # LPCSTR
    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 SetupQueueCopySectionANative = Int32 Function(Pointer<Void>, Pointer<Utf8>, Pointer<Void>, Pointer<Void>, Pointer<Utf8>, Uint32);
typedef SetupQueueCopySectionADart = int Function(Pointer<Void>, Pointer<Utf8>, Pointer<Void>, Pointer<Void>, Pointer<Utf8>, int);
final SetupQueueCopySectionA = DynamicLibrary.open('SETUPAPI.dll')
    .lookupFunction<SetupQueueCopySectionANative, SetupQueueCopySectionADart>('SetupQueueCopySectionA');
// QueueHandle : void* -> Pointer<Void>
// SourceRootPath : LPCSTR optional -> Pointer<Utf8>
// InfHandle : void* -> Pointer<Void>
// ListInfHandle : void* optional -> Pointer<Void>
// Section : LPCSTR -> Pointer<Utf8>
// CopyStyle : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function SetupQueueCopySectionA(
  QueueHandle: Pointer;   // void*
  SourceRootPath: PAnsiChar;   // LPCSTR optional
  InfHandle: Pointer;   // void*
  ListInfHandle: Pointer;   // void* optional
  Section: PAnsiChar;   // LPCSTR
  CopyStyle: DWORD   // DWORD
): BOOL; stdcall;
  external 'SETUPAPI.dll' name 'SetupQueueCopySectionA';
import Foreign
import Foreign.C.Types
import Foreign.C.String

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

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

関連項目

文字セット違い