SetupQueueCopyW
関数シグネチャ
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
BOOL SetupQueueCopyW(
void* QueueHandle,
LPCWSTR SourceRootPath, // optional
LPCWSTR SourcePath, // optional
LPCWSTR SourceFilename,
LPCWSTR SourceDescription, // optional
LPCWSTR SourceTagfile, // optional
LPCWSTR TargetDirectory,
LPCWSTR TargetFilename, // optional
DWORD CopyStyle
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| QueueHandle | void* | in | セットアップファイルキューへのハンドル。 SetupOpenFileQueue によって返されたものを指定します。 |
| SourceRootPath | LPCWSTR | inoptional | このコピーのソースのルート (A:\ など) を指定する null 終端文字列へのポインター。 |
| SourcePath | LPCWSTR | inoptional | ファイルが存在する、SourceRootPath からの相対パスを指定する null 終端文字列へのポインター。このパラメーターは NULL でもかまいません。 |
| SourceFilename | LPCWSTR | in | コピーするファイルのファイル名部分を指定する null 終端文字列へのポインター。 |
| SourceDescription | LPCWSTR | inoptional | ディスクの挿入を求めるプロンプトで使用される、ソースメディアの説明を指定する null 終端文字列へのポインター。このパラメーターは NULL でもかまいません。 |
| SourceTagfile | LPCWSTR | inoptional | タグファイルを指定する null 終端文字列へのポインター。このファイルが SourceRootPath に存在することで、ソースメディアが存在することを示します。このパラメーターは NULL でもかまいません。指定しない場合は、必要に応じてファイル自体がタグファイルとして使用されます。 |
| TargetDirectory | LPCWSTR | in | ファイルのコピー先となるディレクトリを指定する null 終端文字列へのポインター。 |
| TargetFilename | LPCWSTR | inoptional | ターゲットファイルの名前を指定する null 終端文字列へのポインター。このパラメーターは 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:\x86\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:\x86\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
公式ドキュメント
SetupQueueCopy 関数は、1 つのファイルコピー操作をセットアップファイルキューに追加します。(Unicode)
戻り値
関数が成功した場合、戻り値は 0 以外の値です。
関数が失敗した場合、戻り値は 0 です。拡張エラー情報を取得するには、 GetLastError を呼び出します。
解説(Remarks)
ファイルコピー操作のターゲットディレクトリとして UNC ディレクトリを指定する場合は、キューをコミットする前にそのディレクトリが存在することを確認する必要があります。セットアップ関数は UNC ディレクトリの存在確認も作成も行いません。ターゲットの UNC ディレクトリが存在しない場合、ファイルのコピーは失敗します。
setupapi.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして SetupQueueCopy を定義しています。エンコーディング中立のエイリアスを、エンコーディング中立でないコードと混在させて使用すると不一致が生じ、コンパイルエラーや実行時エラーの原因となる可能性があります。詳細については、「Conventions for Function Prototypes」を参照してください。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// SETUPAPI.dll (Unicode / -W)
#include <windows.h>
BOOL SetupQueueCopyW(
void* QueueHandle,
LPCWSTR SourceRootPath, // optional
LPCWSTR SourcePath, // optional
LPCWSTR SourceFilename,
LPCWSTR SourceDescription, // optional
LPCWSTR SourceTagfile, // optional
LPCWSTR TargetDirectory,
LPCWSTR TargetFilename, // optional
DWORD CopyStyle
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool SetupQueueCopyW(
IntPtr QueueHandle, // void*
[MarshalAs(UnmanagedType.LPWStr)] string SourceRootPath, // LPCWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string SourcePath, // LPCWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string SourceFilename, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string SourceDescription, // LPCWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string SourceTagfile, // LPCWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string TargetDirectory, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string TargetFilename, // LPCWSTR optional
uint CopyStyle // DWORD
);<DllImport("SETUPAPI.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupQueueCopyW(
QueueHandle As IntPtr, ' void*
<MarshalAs(UnmanagedType.LPWStr)> SourceRootPath As String, ' LPCWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> SourcePath As String, ' LPCWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> SourceFilename As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> SourceDescription As String, ' LPCWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> SourceTagfile As String, ' LPCWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> TargetDirectory As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> TargetFilename As String, ' LPCWSTR optional
CopyStyle As UInteger ' DWORD
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' QueueHandle : void*
' SourceRootPath : LPCWSTR optional
' SourcePath : LPCWSTR optional
' SourceFilename : LPCWSTR
' SourceDescription : LPCWSTR optional
' SourceTagfile : LPCWSTR optional
' TargetDirectory : LPCWSTR
' TargetFilename : LPCWSTR optional
' CopyStyle : DWORD
Declare PtrSafe Function SetupQueueCopyW Lib "setupapi" ( _
ByVal QueueHandle As LongPtr, _
ByVal SourceRootPath As LongPtr, _
ByVal SourcePath As LongPtr, _
ByVal SourceFilename As LongPtr, _
ByVal SourceDescription As LongPtr, _
ByVal SourceTagfile As LongPtr, _
ByVal TargetDirectory 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
SetupQueueCopyW = ctypes.windll.setupapi.SetupQueueCopyW
SetupQueueCopyW.restype = wintypes.BOOL
SetupQueueCopyW.argtypes = [
ctypes.POINTER(None), # QueueHandle : void*
wintypes.LPCWSTR, # SourceRootPath : LPCWSTR optional
wintypes.LPCWSTR, # SourcePath : LPCWSTR optional
wintypes.LPCWSTR, # SourceFilename : LPCWSTR
wintypes.LPCWSTR, # SourceDescription : LPCWSTR optional
wintypes.LPCWSTR, # SourceTagfile : LPCWSTR optional
wintypes.LPCWSTR, # TargetDirectory : 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')
SetupQueueCopyW = Fiddle::Function.new(
lib['SetupQueueCopyW'],
[
Fiddle::TYPE_VOIDP, # QueueHandle : void*
Fiddle::TYPE_VOIDP, # SourceRootPath : LPCWSTR optional
Fiddle::TYPE_VOIDP, # SourcePath : LPCWSTR optional
Fiddle::TYPE_VOIDP, # SourceFilename : LPCWSTR
Fiddle::TYPE_VOIDP, # SourceDescription : LPCWSTR optional
Fiddle::TYPE_VOIDP, # SourceTagfile : LPCWSTR optional
Fiddle::TYPE_VOIDP, # TargetDirectory : 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 SetupQueueCopyW(
QueueHandle: *mut (), // void*
SourceRootPath: *const u16, // LPCWSTR optional
SourcePath: *const u16, // LPCWSTR optional
SourceFilename: *const u16, // LPCWSTR
SourceDescription: *const u16, // LPCWSTR optional
SourceTagfile: *const u16, // LPCWSTR optional
TargetDirectory: *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 SetupQueueCopyW(IntPtr QueueHandle, [MarshalAs(UnmanagedType.LPWStr)] string SourceRootPath, [MarshalAs(UnmanagedType.LPWStr)] string SourcePath, [MarshalAs(UnmanagedType.LPWStr)] string SourceFilename, [MarshalAs(UnmanagedType.LPWStr)] string SourceDescription, [MarshalAs(UnmanagedType.LPWStr)] string SourceTagfile, [MarshalAs(UnmanagedType.LPWStr)] string TargetDirectory, [MarshalAs(UnmanagedType.LPWStr)] string TargetFilename, uint CopyStyle);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupQueueCopyW' -Namespace Win32 -PassThru
# $api::SetupQueueCopyW(QueueHandle, SourceRootPath, SourcePath, SourceFilename, SourceDescription, SourceTagfile, TargetDirectory, TargetFilename, CopyStyle)#uselib "SETUPAPI.dll"
#func global SetupQueueCopyW "SetupQueueCopyW" wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr
; SetupQueueCopyW QueueHandle, SourceRootPath, SourcePath, SourceFilename, SourceDescription, SourceTagfile, TargetDirectory, TargetFilename, CopyStyle ; 戻り値は stat
; QueueHandle : void* -> "wptr"
; SourceRootPath : LPCWSTR optional -> "wptr"
; SourcePath : LPCWSTR optional -> "wptr"
; SourceFilename : LPCWSTR -> "wptr"
; SourceDescription : LPCWSTR optional -> "wptr"
; SourceTagfile : LPCWSTR optional -> "wptr"
; TargetDirectory : LPCWSTR -> "wptr"
; TargetFilename : LPCWSTR optional -> "wptr"
; CopyStyle : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "SETUPAPI.dll"
#cfunc global SetupQueueCopyW "SetupQueueCopyW" sptr, wstr, wstr, wstr, wstr, wstr, wstr, wstr, int
; res = SetupQueueCopyW(QueueHandle, SourceRootPath, SourcePath, SourceFilename, SourceDescription, SourceTagfile, TargetDirectory, TargetFilename, CopyStyle)
; QueueHandle : void* -> "sptr"
; SourceRootPath : LPCWSTR optional -> "wstr"
; SourcePath : LPCWSTR optional -> "wstr"
; SourceFilename : LPCWSTR -> "wstr"
; SourceDescription : LPCWSTR optional -> "wstr"
; SourceTagfile : LPCWSTR optional -> "wstr"
; TargetDirectory : LPCWSTR -> "wstr"
; TargetFilename : LPCWSTR optional -> "wstr"
; CopyStyle : DWORD -> "int"; BOOL SetupQueueCopyW(void* QueueHandle, LPCWSTR SourceRootPath, LPCWSTR SourcePath, LPCWSTR SourceFilename, LPCWSTR SourceDescription, LPCWSTR SourceTagfile, LPCWSTR TargetDirectory, LPCWSTR TargetFilename, DWORD CopyStyle)
#uselib "SETUPAPI.dll"
#cfunc global SetupQueueCopyW "SetupQueueCopyW" intptr, wstr, wstr, wstr, wstr, wstr, wstr, wstr, int
; res = SetupQueueCopyW(QueueHandle, SourceRootPath, SourcePath, SourceFilename, SourceDescription, SourceTagfile, TargetDirectory, TargetFilename, CopyStyle)
; QueueHandle : void* -> "intptr"
; SourceRootPath : LPCWSTR optional -> "wstr"
; SourcePath : LPCWSTR optional -> "wstr"
; SourceFilename : LPCWSTR -> "wstr"
; SourceDescription : LPCWSTR optional -> "wstr"
; SourceTagfile : LPCWSTR optional -> "wstr"
; TargetDirectory : LPCWSTR -> "wstr"
; TargetFilename : LPCWSTR optional -> "wstr"
; CopyStyle : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
procSetupQueueCopyW = setupapi.NewProc("SetupQueueCopyW")
)
// QueueHandle (void*), SourceRootPath (LPCWSTR optional), SourcePath (LPCWSTR optional), SourceFilename (LPCWSTR), SourceDescription (LPCWSTR optional), SourceTagfile (LPCWSTR optional), TargetDirectory (LPCWSTR), TargetFilename (LPCWSTR optional), CopyStyle (DWORD)
r1, _, err := procSetupQueueCopyW.Call(
uintptr(QueueHandle),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(SourceRootPath))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(SourcePath))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(SourceFilename))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(SourceDescription))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(SourceTagfile))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(TargetDirectory))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(TargetFilename))),
uintptr(CopyStyle),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetupQueueCopyW(
QueueHandle: Pointer; // void*
SourceRootPath: PWideChar; // LPCWSTR optional
SourcePath: PWideChar; // LPCWSTR optional
SourceFilename: PWideChar; // LPCWSTR
SourceDescription: PWideChar; // LPCWSTR optional
SourceTagfile: PWideChar; // LPCWSTR optional
TargetDirectory: PWideChar; // LPCWSTR
TargetFilename: PWideChar; // LPCWSTR optional
CopyStyle: DWORD // DWORD
): BOOL; stdcall;
external 'SETUPAPI.dll' name 'SetupQueueCopyW';result := DllCall("SETUPAPI\SetupQueueCopyW"
, "Ptr", QueueHandle ; void*
, "WStr", SourceRootPath ; LPCWSTR optional
, "WStr", SourcePath ; LPCWSTR optional
, "WStr", SourceFilename ; LPCWSTR
, "WStr", SourceDescription ; LPCWSTR optional
, "WStr", SourceTagfile ; LPCWSTR optional
, "WStr", TargetDirectory ; LPCWSTR
, "WStr", TargetFilename ; LPCWSTR optional
, "UInt", CopyStyle ; DWORD
, "Int") ; return: BOOL●SetupQueueCopyW(QueueHandle, SourceRootPath, SourcePath, SourceFilename, SourceDescription, SourceTagfile, TargetDirectory, TargetFilename, CopyStyle) = DLL("SETUPAPI.dll", "bool SetupQueueCopyW(void*, char*, char*, char*, char*, char*, char*, char*, dword)")
# 呼び出し: SetupQueueCopyW(QueueHandle, SourceRootPath, SourcePath, SourceFilename, SourceDescription, SourceTagfile, TargetDirectory, TargetFilename, CopyStyle)
# QueueHandle : void* -> "void*"
# SourceRootPath : LPCWSTR optional -> "char*"
# SourcePath : LPCWSTR optional -> "char*"
# SourceFilename : LPCWSTR -> "char*"
# SourceDescription : LPCWSTR optional -> "char*"
# SourceTagfile : LPCWSTR optional -> "char*"
# TargetDirectory : 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 SetupQueueCopyW(
QueueHandle: ?*anyopaque, // void*
SourceRootPath: [*c]const u16, // LPCWSTR optional
SourcePath: [*c]const u16, // LPCWSTR optional
SourceFilename: [*c]const u16, // LPCWSTR
SourceDescription: [*c]const u16, // LPCWSTR optional
SourceTagfile: [*c]const u16, // LPCWSTR optional
TargetDirectory: [*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 SetupQueueCopyW(
QueueHandle: pointer, # void*
SourceRootPath: WideCString, # LPCWSTR optional
SourcePath: WideCString, # LPCWSTR optional
SourceFilename: WideCString, # LPCWSTR
SourceDescription: WideCString, # LPCWSTR optional
SourceTagfile: WideCString, # LPCWSTR optional
TargetDirectory: WideCString, # LPCWSTR
TargetFilename: WideCString, # LPCWSTR optional
CopyStyle: uint32 # DWORD
): int32 {.importc: "SetupQueueCopyW", stdcall, dynlib: "SETUPAPI.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "setupapi");
extern(Windows)
int SetupQueueCopyW(
void* QueueHandle, // void*
const(wchar)* SourceRootPath, // LPCWSTR optional
const(wchar)* SourcePath, // LPCWSTR optional
const(wchar)* SourceFilename, // LPCWSTR
const(wchar)* SourceDescription, // LPCWSTR optional
const(wchar)* SourceTagfile, // LPCWSTR optional
const(wchar)* TargetDirectory, // LPCWSTR
const(wchar)* TargetFilename, // LPCWSTR optional
uint CopyStyle // DWORD
);ccall((:SetupQueueCopyW, "SETUPAPI.dll"), stdcall, Int32,
(Ptr{Cvoid}, Cwstring, Cwstring, Cwstring, Cwstring, Cwstring, Cwstring, Cwstring, UInt32),
QueueHandle, SourceRootPath, SourcePath, SourceFilename, SourceDescription, SourceTagfile, TargetDirectory, TargetFilename, CopyStyle)
# QueueHandle : void* -> Ptr{Cvoid}
# SourceRootPath : LPCWSTR optional -> Cwstring
# SourcePath : LPCWSTR optional -> Cwstring
# SourceFilename : LPCWSTR -> Cwstring
# SourceDescription : LPCWSTR optional -> Cwstring
# SourceTagfile : LPCWSTR optional -> Cwstring
# TargetDirectory : 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 SetupQueueCopyW(
void* QueueHandle,
const uint16_t* SourceRootPath,
const uint16_t* SourcePath,
const uint16_t* SourceFilename,
const uint16_t* SourceDescription,
const uint16_t* SourceTagfile,
const uint16_t* TargetDirectory,
const uint16_t* TargetFilename,
uint32_t CopyStyle);
]]
local setupapi = ffi.load("setupapi")
-- setupapi.SetupQueueCopyW(QueueHandle, SourceRootPath, SourcePath, SourceFilename, SourceDescription, SourceTagfile, TargetDirectory, TargetFilename, CopyStyle)
-- QueueHandle : void*
-- SourceRootPath : LPCWSTR optional
-- SourcePath : LPCWSTR optional
-- SourceFilename : LPCWSTR
-- SourceDescription : LPCWSTR optional
-- SourceTagfile : LPCWSTR optional
-- TargetDirectory : 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 SetupQueueCopyW = lib.func('__stdcall', 'SetupQueueCopyW', 'int32_t', ['void *', 'str16', 'str16', 'str16', 'str16', 'str16', 'str16', 'str16', 'uint32_t']);
// SetupQueueCopyW(QueueHandle, SourceRootPath, SourcePath, SourceFilename, SourceDescription, SourceTagfile, TargetDirectory, TargetFilename, CopyStyle)
// QueueHandle : void* -> 'void *'
// SourceRootPath : LPCWSTR optional -> 'str16'
// SourcePath : LPCWSTR optional -> 'str16'
// SourceFilename : LPCWSTR -> 'str16'
// SourceDescription : LPCWSTR optional -> 'str16'
// SourceTagfile : LPCWSTR optional -> 'str16'
// TargetDirectory : LPCWSTR -> 'str16'
// TargetFilename : LPCWSTR optional -> 'str16'
// CopyStyle : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("SETUPAPI.dll", {
SetupQueueCopyW: { parameters: ["pointer", "buffer", "buffer", "buffer", "buffer", "buffer", "buffer", "buffer", "u32"], result: "i32" },
});
// lib.symbols.SetupQueueCopyW(QueueHandle, SourceRootPath, SourcePath, SourceFilename, SourceDescription, SourceTagfile, TargetDirectory, TargetFilename, CopyStyle)
// QueueHandle : void* -> "pointer"
// SourceRootPath : LPCWSTR optional -> "buffer"
// SourcePath : LPCWSTR optional -> "buffer"
// SourceFilename : LPCWSTR -> "buffer"
// SourceDescription : LPCWSTR optional -> "buffer"
// SourceTagfile : LPCWSTR optional -> "buffer"
// TargetDirectory : 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 SetupQueueCopyW(
void* QueueHandle,
const uint16_t* SourceRootPath,
const uint16_t* SourcePath,
const uint16_t* SourceFilename,
const uint16_t* SourceDescription,
const uint16_t* SourceTagfile,
const uint16_t* TargetDirectory,
const uint16_t* TargetFilename,
uint32_t CopyStyle);
C, "SETUPAPI.dll");
// $ffi->SetupQueueCopyW(QueueHandle, SourceRootPath, SourcePath, SourceFilename, SourceDescription, SourceTagfile, TargetDirectory, TargetFilename, CopyStyle);
// QueueHandle : void*
// SourceRootPath : LPCWSTR optional
// SourcePath : LPCWSTR optional
// SourceFilename : LPCWSTR
// SourceDescription : LPCWSTR optional
// SourceTagfile : LPCWSTR optional
// TargetDirectory : 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 SetupQueueCopyW(
Pointer QueueHandle, // void*
WString SourceRootPath, // LPCWSTR optional
WString SourcePath, // LPCWSTR optional
WString SourceFilename, // LPCWSTR
WString SourceDescription, // LPCWSTR optional
WString SourceTagfile, // LPCWSTR optional
WString TargetDirectory, // LPCWSTR
WString TargetFilename, // LPCWSTR optional
int CopyStyle // DWORD
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("setupapi")]
lib LibSETUPAPI
fun SetupQueueCopyW = SetupQueueCopyW(
QueueHandle : Void*, # void*
SourceRootPath : UInt16*, # LPCWSTR optional
SourcePath : UInt16*, # LPCWSTR optional
SourceFilename : UInt16*, # LPCWSTR
SourceDescription : UInt16*, # LPCWSTR optional
SourceTagfile : UInt16*, # LPCWSTR optional
TargetDirectory : 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 SetupQueueCopyWNative = Int32 Function(Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Uint32);
typedef SetupQueueCopyWDart = int Function(Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, int);
final SetupQueueCopyW = DynamicLibrary.open('SETUPAPI.dll')
.lookupFunction<SetupQueueCopyWNative, SetupQueueCopyWDart>('SetupQueueCopyW');
// QueueHandle : void* -> Pointer<Void>
// SourceRootPath : LPCWSTR optional -> Pointer<Utf16>
// SourcePath : LPCWSTR optional -> Pointer<Utf16>
// SourceFilename : LPCWSTR -> Pointer<Utf16>
// SourceDescription : LPCWSTR optional -> Pointer<Utf16>
// SourceTagfile : LPCWSTR optional -> Pointer<Utf16>
// TargetDirectory : LPCWSTR -> Pointer<Utf16>
// TargetFilename : LPCWSTR optional -> Pointer<Utf16>
// CopyStyle : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SetupQueueCopyW(
QueueHandle: Pointer; // void*
SourceRootPath: PWideChar; // LPCWSTR optional
SourcePath: PWideChar; // LPCWSTR optional
SourceFilename: PWideChar; // LPCWSTR
SourceDescription: PWideChar; // LPCWSTR optional
SourceTagfile: PWideChar; // LPCWSTR optional
TargetDirectory: PWideChar; // LPCWSTR
TargetFilename: PWideChar; // LPCWSTR optional
CopyStyle: DWORD // DWORD
): BOOL; stdcall;
external 'SETUPAPI.dll' name 'SetupQueueCopyW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SetupQueueCopyW"
c_SetupQueueCopyW :: Ptr () -> CWString -> CWString -> CWString -> CWString -> CWString -> CWString -> CWString -> Word32 -> IO CInt
-- QueueHandle : void* -> Ptr ()
-- SourceRootPath : LPCWSTR optional -> CWString
-- SourcePath : LPCWSTR optional -> CWString
-- SourceFilename : LPCWSTR -> CWString
-- SourceDescription : LPCWSTR optional -> CWString
-- SourceTagfile : LPCWSTR optional -> CWString
-- TargetDirectory : LPCWSTR -> CWString
-- TargetFilename : LPCWSTR optional -> CWString
-- CopyStyle : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let setupqueuecopyw =
foreign "SetupQueueCopyW"
((ptr void) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> uint32_t @-> returning int32_t)
(* QueueHandle : void* -> (ptr void) *)
(* SourceRootPath : LPCWSTR optional -> (ptr uint16_t) *)
(* SourcePath : LPCWSTR optional -> (ptr uint16_t) *)
(* SourceFilename : LPCWSTR -> (ptr uint16_t) *)
(* SourceDescription : LPCWSTR optional -> (ptr uint16_t) *)
(* SourceTagfile : LPCWSTR optional -> (ptr uint16_t) *)
(* TargetDirectory : 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 ("SetupQueueCopyW" setup-queue-copy-w :convention :stdcall) :int32
(queue-handle :pointer) ; void*
(source-root-path (:string :encoding :utf-16le)) ; LPCWSTR optional
(source-path (:string :encoding :utf-16le)) ; LPCWSTR optional
(source-filename (:string :encoding :utf-16le)) ; LPCWSTR
(source-description (:string :encoding :utf-16le)) ; LPCWSTR optional
(source-tagfile (:string :encoding :utf-16le)) ; LPCWSTR optional
(target-directory (: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 $SetupQueueCopyW = Win32::API::More->new('SETUPAPI',
'BOOL SetupQueueCopyW(LPVOID QueueHandle, LPCWSTR SourceRootPath, LPCWSTR SourcePath, LPCWSTR SourceFilename, LPCWSTR SourceDescription, LPCWSTR SourceTagfile, LPCWSTR TargetDirectory, LPCWSTR TargetFilename, DWORD CopyStyle)');
# my $ret = $SetupQueueCopyW->Call($QueueHandle, $SourceRootPath, $SourcePath, $SourceFilename, $SourceDescription, $SourceTagfile, $TargetDirectory, $TargetFilename, $CopyStyle);
# QueueHandle : void* -> LPVOID
# SourceRootPath : LPCWSTR optional -> LPCWSTR
# SourcePath : LPCWSTR optional -> LPCWSTR
# SourceFilename : LPCWSTR -> LPCWSTR
# SourceDescription : LPCWSTR optional -> LPCWSTR
# SourceTagfile : LPCWSTR optional -> LPCWSTR
# TargetDirectory : LPCWSTR -> LPCWSTR
# TargetFilename : LPCWSTR optional -> LPCWSTR
# CopyStyle : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
- f SetupQueueCopyA (ANSI版) — ファイルキューにコピー操作を追加する(ANSI)。
- f SetupQueueCopySectionW — INFセクションのファイル群をコピー操作としてキューに追加する(Unicode)。
- f SetupQueueDefaultCopyW — INFの既定設定に従いコピー操作をキューに追加する(Unicode)。
- f SetupQueueDeleteW — ファイルキューに削除操作を追加する(Unicode)。
- f SetupQueueRenameW — ファイルキューに名前変更操作を追加する(Unicode)。