SetupQueueCopySectionW
関数シグネチャ
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
BOOL SetupQueueCopySectionW(
void* QueueHandle,
LPCWSTR SourceRootPath, // optional
void* InfHandle,
void* ListInfHandle, // optional
LPCWSTR Section,
DWORD CopyStyle
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| QueueHandle | void* | in | セットアップファイルキューのハンドル。 SetupOpenFileQueue によって返されます。 |
| SourceRootPath | LPCWSTR | inoptional | このコピーのソースのルート (A:\ など) を指定する、null で終わる文字列へのポインター。 |
| InfHandle | void* | in | SourceDisksFiles セクションおよび SourceDisksNames セクションを含む、開かれた INF ファイルのハンドル。ListInfHandle が指定されていない場合、InfHandle にセクション名が含まれます。ユーザーのシステムに対応するプラットフォーム固有のセクション (SourceDisksNames.x86 や SourceDisksFiles.x86 など) が存在する場合は、そのプラットフォーム固有のセクションが使用されます。 |
| ListInfHandle | void* | inoptional | コピー用にキューへ登録するセクションを含む、開かれた INF ファイルの省略可能なハンドル。ListInfHandle が指定されていない場合、InfHandle にそのセクションが含まれているものと見なされます。 |
| Section | LPCWSTR | in | コピー用にキューへ登録するセクションの名前を指定する、null で終わる文字列へのポインター。 |
| CopyStyle | DWORD | in | ファイルコピー操作の動作を制御するフラグ。これらのフラグには、次の値を組み合わせて指定できます。 SP_COPY_DELETESOURCEコピーが成功した後にソースファイルを削除します。削除に失敗しても呼び出し元には通知されません。 SP_COPY_REPLACEONLYコピー先のパスにあるファイルを上書きすることになる場合にのみ、ファイルをコピーします。 SP_COPY_NEWER_OR_SAMEコピーする各ファイルについて、そのバージョンリソースが、コピー先にある既存のコピーとバージョンが等しいか、またはそれより新しくないことを示しているかどうかを調べます。 バージョンチェックで使用されるファイルのバージョン情報は、バージョン関数によって設定される VS_FIXEDFILEINFO 構造体の dwFileVersionMS メンバーおよび dwFileVersionLS メンバーに指定されているものです。いずれかのファイルにバージョンリソースが無い場合、または両者のバージョン情報が同一の場合は、ソースファイルの方が新しいと見なされます。 ソースファイルのバージョンが等しくも新しくもなく、かつ CopyMsgHandler が指定されている場合は、呼び出し元に通知され、コピーをキャンセルできます。CopyMsgHandler が指定されていない場合、ファイルはコピーされません。 SP_COPY_NEWER_ONLYコピーする各ファイルについて、そのバージョンリソースが、コピー先にある既存のコピーより新しくないことを示しているかどうかを調べます。ソースファイルの方が新しく、既存のコピー先とバージョンが等しくない場合は、ファイルがコピーされます。 SP_COPY_NOOVERWRITEコピー先のファイルが存在するかどうかを確認し、存在する場合は呼び出し元に通知します。呼び出し元はコピーを拒否できます。CopyMsgHandler が指定されていない場合、ファイルは上書きされません。 SP_COPY_NODECOMPファイルを展開 (圧縮解除) しません。このフラグを設定すると、コピー先のファイルには (該当する場合でも) ソース名の非圧縮形式の名前が付けられません。たとえば、f:\x86s\cmd.ex_ を \install\temp にコピーすると、コピー先のファイルは \install\temp\cmd.ex_ になります。SP_COPY_NODECOMP フラグを指定しなかった場合は、ファイルが展開され、コピー先は \install\temp\cmd.exe という名前になります。DestinationName が指定されている場合、そのファイル名部分は取り除かれ、ソースファイルのファイル名に置き換えられます。SP_COPY_NODECOMP を指定した場合、言語情報やバージョン情報のチェックは行えません。 SP_COPY_LANGUAGEAWAREコピーする各ファイルについて、その言語が、コピー先に既に存在するファイルの言語と異なるかどうかを調べます。異なっており、かつ CopyMsgHandler が指定されている場合は、呼び出し元に通知され、コピーをキャンセルできます。CopyMsgHandler が指定されていない場合、ファイルはコピーされません。 SP_COPY_SOURCE_ABSOLUTESourceFile は完全なソースパスです。INF ファイルの SourceDisksNames セクションで検索しません。 SP_COPY_SOURCEPATH_ABSOLUTESourcePathRoot はソースファイルの完全なパス部分です。ファイルが存在するソースメディアについて、INF ファイルの SourceDisksNames セクションに指定された相対ソースを無視します。SP_COPY_SOURCE_ABSOLUTE が指定されている場合、このフラグは無視されます。 SP_COPY_FORCE_IN_USEコピー先が存在する場合、それが使用中であるものとして扱い、次回のシステム再起動時にコピーするようファイルをキューに登録します。 SP_COPY_IN_USE_NEEDS_REBOOTコピー操作中にファイルが使用中だった場合、システムの再起動が必要であることをユーザーに通知します。 SP_COPY_NOSKIPファイルをスキップする選択肢をユーザーに与えません。 SP_COPY_FORCE_NOOVERWRITEコピー先のファイルが存在するかどうかを確認し、存在する場合はファイルを上書きしません。呼び出し元には通知されません。 SP_COPY_FORCE_NEWERコピーする各ファイルについて、そのバージョンリソース (イメージファイル以外の場合はタイムスタンプ) が、コピー先にある既存のコピーより新しくないことを示しているかどうかを調べます。コピーするファイルの方が新しくない場合、ファイルはコピーされません。呼び出し元には通知されません。 SP_COPY_WARNIFSKIPユーザーがファイルをスキップしようとした場合、ファイルをスキップするとインストールに影響する可能性があることを警告します。(システムにとって重要なファイルに使用します。) - CopyStyle.SP_COPY_DELETESOURCEコピーが成功した後にソースファイルを削除します。削除に失敗しても呼び出し元には通知されません。 - CopyStyle.SP_COPY_FORCE_IN_USEコピー先が存在する場合、それが使用中であるものとして扱い、次回のシステム再起動時にコピーするようファイルをキューに登録します。 - CopyStyle.SP_COPY_FORCE_NEWERコピーする各ファイルについて、そのバージョンリソース (イメージファイル以外の場合はタイムスタンプ) が、コピー先にある既存のコピーより新しくないことを示しているかどうかを調べます。コピーするファイルの方が新しくない場合、ファイルはコピーされません。呼び出し元には通知されません。 - CopyStyle.SP_COPY_FORCE_NOOVERWRITEコピー先のファイルが存在するかどうかを確認し、存在する場合はファイルを上書きしません。呼び出し元には通知されません。 - CopyStyle.SP_COPY_IN_USE_NEEDS_REBOOTコピー操作中にファイルが使用中だった場合、システムの再起動が必要であることをユーザーに通知します。 - CopyStyle.SP_COPY_LANGUAGEAWAREコピーする各ファイルについて、その言語が、コピー先に既に存在するファイルの言語と異なるかどうかを調べます。異なっており、かつ CopyMsgHandler が指定されている場合は、呼び出し元に通知され、コピーをキャンセルできます。CopyMsgHandler が指定されていない場合、ファイルはコピーされません。 - CopyStyle.SP_COPY_NEWER_ONLYコピーする各ファイルについて、そのバージョンリソースが、コピー先にある既存のコピーより新しくないことを示しているかどうかを調べます。ソースファイルの方が新しく、既存のコピー先とバージョンが等しくない場合は、ファイルがコピーされます。 - CopyStyle.SP_COPY_NEWER_OR_SAMEコピーする各ファイルについて、そのバージョンリソースが、コピー先にある既存のコピーとバージョンが等しいか、またはそれより新しくないことを示しているかどうかを調べます。 バージョンチェックで使用されるファイルのバージョン情報は、バージョン関数によって設定される VS_FIXEDFILEINFO 構造体の dwFileVersionMS メンバーおよび dwFileVersionLS メンバーに指定されているものです。いずれかのファイルにバージョンリソースが無い場合、または両者のバージョン情報が同一の場合は、ソースファイルの方が新しいと見なされます。 ソースファイルのバージョンが等しくも新しくもなく、かつ CopyMsgHandler が指定されている場合は、呼び出し元に通知され、コピーをキャンセルできます。CopyMsgHandler が指定されていない場合、ファイルはコピーされません。 - CopyStyle.SP_COPY_NODECOMPファイルを展開 (圧縮解除) しません。このフラグを設定すると、コピー先のファイルには (該当する場合でも) ソース名の非圧縮形式の名前が付けられません。たとえば、f:\x86s\cmd.ex_ を \install\temp にコピーすると、コピー先のファイルは \install\temp\cmd.ex_ になります。SP_COPY_NODECOMP フラグを指定しなかった場合は、ファイルが展開され、コピー先は \install\temp\cmd.exe という名前になります。DestinationName が指定されている場合、そのファイル名部分は取り除かれ、ソースファイルのファイル名に置き換えられます。SP_COPY_NODECOMP を指定した場合、言語情報やバージョン情報のチェックは行えません。 - CopyStyle.SP_COPY_NOOVERWRITEコピー先のファイルが存在するかどうかを確認し、存在する場合は呼び出し元に通知します。呼び出し元はコピーを拒否できます。CopyMsgHandler が指定されていない場合、ファイルは上書きされません。 - CopyStyle.SP_COPY_NOSKIPファイルをスキップする選択肢をユーザーに与えません。 - CopyStyle.SP_COPY_REPLACEONLYコピー先のパスにあるファイルを上書きすることになる場合にのみ、ファイルをコピーします。 - CopyStyle.SP_COPY_SOURCEPATH_ABSOLUTESourcePathRoot はソースファイルの完全なパス部分です。ファイルが存在するソースメディアについて、INF ファイルの SourceDisksNames セクションに指定された相対ソースを無視します。SP_COPY_SOURCE_ABSOLUTE が指定されている場合、このフラグは無視されます。 - CopyStyle.SP_COPY_SOURCE_ABSOLUTESourceFile は完全なソースパスです。INF ファイルの SourceDisksNames セクションで検索しません。 - CopyStyle.SP_COPY_WARNIFSKIPユーザーがファイルをスキップしようとした場合、ファイルをスキップするとインストールに影響する可能性があることを警告します。(システムにとって重要なファイルに使用します。) |
戻り値の型: BOOL
公式ドキュメント
SetupQueueCopySection 関数は、INF ファイルのセクションに含まれるすべてのファイルを、コピーするためにセットアップキューに登録します。(Unicode)
戻り値
関数が成功した場合、戻り値は 0 以外の値です。
関数が失敗した場合、戻り値は 0 です。拡張エラー情報を取得するには、 GetLastError を呼び出します。
解説(Remarks)
ファイルコピー操作のコピー先ディレクトリとして UNC ディレクトリを指定する場合は、キューをコミットする前にそのディレクトリが存在することを確認する必要があります。セットアップ関数は UNC ディレクトリの存在を確認せず、また作成もしません。コピー先の UNC ディレクトリが存在しない場合、ファイルコピーは失敗します。
この関数には Windows の INF ファイルが必要です。一部の古い形式の INF ファイルはサポートされない場合があります。
setupapi.h ヘッダーは、UNICODE プリプロセッサ定数の定義に応じて、この関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして SetupQueueCopySection を定義しています。エンコード中立のエイリアスの使用を、エンコード中立でないコードと混在させると、不一致が生じ、コンパイルエラーや実行時エラーの原因となることがあります。詳細については、「Conventions for Function Prototypes」を参照してください。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// 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 // BOOLfunction 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 変換を行う。関連項目
- f SetupQueueCopySectionA (ANSI版) — INFセクションのファイル群をコピー操作としてキューに追加する(ANSI)。
- f SetupQueueCopyW — ファイルキューにコピー操作を追加する(Unicode)。
- f SetupQueueDefaultCopyW — INFの既定設定に従いコピー操作をキューに追加する(Unicode)。