SP_FILE_COPY_PARAMS_W
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| cbSize | DWORD | 4 | +0 | +0 | 構造体のサイズ (バイト単位)。sizeof(SP_FILE_COPY_PARAMS) の値を設定します。 | ||||||||||||||||||||||||||||||||
| QueueHandle | void* | 8/4 | +4 | +4 | セットアップファイルキューへのハンドルです。 SetupOpenFileQueue によって返されます。 | ||||||||||||||||||||||||||||||||
| SourceRootPath | LPWSTR | 8/4 | +12 | +8 | このコピーのコピー元のルート (A:\ など) を指す省略可能なポインターです。 | ||||||||||||||||||||||||||||||||
| SourcePath | LPWSTR | 8/4 | +20 | +12 | ファイルが存在する、SourceRootPath からの相対パスを指す省略可能なポインターです。 | ||||||||||||||||||||||||||||||||
| SourceFilename | LPWSTR | 8/4 | +28 | +16 | コピーするファイルのファイル名部分です。 | ||||||||||||||||||||||||||||||||
| SourceDescription | LPWSTR | 8/4 | +36 | +20 | ディスクの入れ替えを促すプロンプトで使用される、ソースメディアの説明を指す省略可能なポインターです。 | ||||||||||||||||||||||||||||||||
| SourceTagfile | LPWSTR | 8/4 | +44 | +24 | SourceRootPath に存在することでソースメディアの存在を示すタグファイルを指す省略可能なポインターです。指定しない場合、必要であればファイル自体がタグファイルとして使用されます。 | ||||||||||||||||||||||||||||||||
| TargetDirectory | LPWSTR | 8/4 | +52 | +28 | ファイルのコピー先となるディレクトリです。 | ||||||||||||||||||||||||||||||||
| TargetFilename | LPWSTR | 8/4 | +60 | +32 | ターゲットファイルの名前を指す省略可能なポインターです。指定しない場合、ターゲットファイルはソースファイルと同じ名前になります。 | ||||||||||||||||||||||||||||||||
| CopyStyle | DWORD | 4 | +68 | +36 | ファイルコピー操作の動作を制御するフラグです。これらのフラグには、次の値の組み合わせを指定できます。
| ||||||||||||||||||||||||||||||||
| LayoutInf | void* | 8/4 | +72 | +40 | ソース情報の取得に使用する INF へのハンドルです。 | ||||||||||||||||||||||||||||||||
| SecurityDescriptor | LPWSTR | 8/4 | +80 | +44 | ファイルに適用する ACL を指定する、省略可能なセキュリティ記述子文字列です。 |
公式ドキュメント
SP_FILE_COPY_PARAMS 構造体は、単一のファイルコピー操作を記述します。
解説(Remarks)
setupapi.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいて、この関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして SP_FILE_COPY_PARAMS を定義します。エンコードに依存しないエイリアスと、エンコードに依存しないわけではないコードを混在させて使用すると、不一致が生じ、コンパイルエラーや実行時エラーの原因となる可能性があります。詳細については、関数プロトタイプの規則を参照してください。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での定義
#include <windows.h>
// SP_FILE_COPY_PARAMS_W (x64 88 / x86 48 バイト)
#pragma pack(push, 1)
typedef struct SP_FILE_COPY_PARAMS_W {
DWORD cbSize;
void* QueueHandle;
LPWSTR SourceRootPath;
LPWSTR SourcePath;
LPWSTR SourceFilename;
LPWSTR SourceDescription;
LPWSTR SourceTagfile;
LPWSTR TargetDirectory;
LPWSTR TargetFilename;
DWORD CopyStyle;
void* LayoutInf;
LPWSTR SecurityDescriptor;
} SP_FILE_COPY_PARAMS_W;
#pragma pack(pop)using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct SP_FILE_COPY_PARAMS_W
{
public uint cbSize;
public IntPtr QueueHandle;
public IntPtr SourceRootPath;
public IntPtr SourcePath;
public IntPtr SourceFilename;
public IntPtr SourceDescription;
public IntPtr SourceTagfile;
public IntPtr TargetDirectory;
public IntPtr TargetFilename;
public uint CopyStyle;
public IntPtr LayoutInf;
public IntPtr SecurityDescriptor;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure SP_FILE_COPY_PARAMS_W
Public cbSize As UInteger
Public QueueHandle As IntPtr
Public SourceRootPath As IntPtr
Public SourcePath As IntPtr
Public SourceFilename As IntPtr
Public SourceDescription As IntPtr
Public SourceTagfile As IntPtr
Public TargetDirectory As IntPtr
Public TargetFilename As IntPtr
Public CopyStyle As UInteger
Public LayoutInf As IntPtr
Public SecurityDescriptor As IntPtr
End Structureimport ctypes
from ctypes import wintypes
class SP_FILE_COPY_PARAMS_W(ctypes.Structure):
_pack_ = 1
_fields_ = [
("cbSize", wintypes.DWORD),
("QueueHandle", ctypes.c_void_p),
("SourceRootPath", ctypes.c_void_p),
("SourcePath", ctypes.c_void_p),
("SourceFilename", ctypes.c_void_p),
("SourceDescription", ctypes.c_void_p),
("SourceTagfile", ctypes.c_void_p),
("TargetDirectory", ctypes.c_void_p),
("TargetFilename", ctypes.c_void_p),
("CopyStyle", wintypes.DWORD),
("LayoutInf", ctypes.c_void_p),
("SecurityDescriptor", ctypes.c_void_p),
]#[repr(C, packed(1))]
pub struct SP_FILE_COPY_PARAMS_W {
pub cbSize: u32,
pub QueueHandle: *mut core::ffi::c_void,
pub SourceRootPath: *mut core::ffi::c_void,
pub SourcePath: *mut core::ffi::c_void,
pub SourceFilename: *mut core::ffi::c_void,
pub SourceDescription: *mut core::ffi::c_void,
pub SourceTagfile: *mut core::ffi::c_void,
pub TargetDirectory: *mut core::ffi::c_void,
pub TargetFilename: *mut core::ffi::c_void,
pub CopyStyle: u32,
pub LayoutInf: *mut core::ffi::c_void,
pub SecurityDescriptor: *mut core::ffi::c_void,
}import "golang.org/x/sys/windows"
type SP_FILE_COPY_PARAMS_W struct {
cbSize uint32
QueueHandle uintptr
SourceRootPath uintptr
SourcePath uintptr
SourceFilename uintptr
SourceDescription uintptr
SourceTagfile uintptr
TargetDirectory uintptr
TargetFilename uintptr
CopyStyle uint32
LayoutInf uintptr
SecurityDescriptor uintptr
}type
SP_FILE_COPY_PARAMS_W = packed record
cbSize: DWORD;
QueueHandle: Pointer;
SourceRootPath: Pointer;
SourcePath: Pointer;
SourceFilename: Pointer;
SourceDescription: Pointer;
SourceTagfile: Pointer;
TargetDirectory: Pointer;
TargetFilename: Pointer;
CopyStyle: DWORD;
LayoutInf: Pointer;
SecurityDescriptor: Pointer;
end;const SP_FILE_COPY_PARAMS_W = extern struct {
cbSize: u32,
QueueHandle: ?*anyopaque,
SourceRootPath: ?*anyopaque,
SourcePath: ?*anyopaque,
SourceFilename: ?*anyopaque,
SourceDescription: ?*anyopaque,
SourceTagfile: ?*anyopaque,
TargetDirectory: ?*anyopaque,
TargetFilename: ?*anyopaque,
CopyStyle: u32,
LayoutInf: ?*anyopaque,
SecurityDescriptor: ?*anyopaque,
};type
SP_FILE_COPY_PARAMS_W {.packed.} = object
cbSize: uint32
QueueHandle: pointer
SourceRootPath: pointer
SourcePath: pointer
SourceFilename: pointer
SourceDescription: pointer
SourceTagfile: pointer
TargetDirectory: pointer
TargetFilename: pointer
CopyStyle: uint32
LayoutInf: pointer
SecurityDescriptor: pointeralign(1)
struct SP_FILE_COPY_PARAMS_W
{
uint cbSize;
void* QueueHandle;
void* SourceRootPath;
void* SourcePath;
void* SourceFilename;
void* SourceDescription;
void* SourceTagfile;
void* TargetDirectory;
void* TargetFilename;
uint CopyStyle;
void* LayoutInf;
void* SecurityDescriptor;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; SP_FILE_COPY_PARAMS_W サイズ: 48 バイト(x86)
dim st, 12 ; 4byte整数×12(構造体サイズ 48 / 4 切り上げ)
; cbSize : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; QueueHandle : void* (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; SourceRootPath : LPWSTR (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; SourcePath : LPWSTR (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; SourceFilename : LPWSTR (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; SourceDescription : LPWSTR (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; SourceTagfile : LPWSTR (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; TargetDirectory : LPWSTR (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; TargetFilename : LPWSTR (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; CopyStyle : DWORD (+36, 4byte) st.9 = 値 / 値 = st.9 (lpoke/lpeek も可)
; LayoutInf : void* (+40, 4byte) st.10 = 値 / 値 = st.10 (lpoke/lpeek も可)
; SecurityDescriptor : LPWSTR (+44, 4byte) st.11 = 値 / 値 = st.11 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; SP_FILE_COPY_PARAMS_W サイズ: 88 バイト(x64)
dim st, 22 ; 4byte整数×22(構造体サイズ 88 / 4 切り上げ)
; cbSize : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; QueueHandle : void* (+4, 8byte) qpoke st,4,値 / qpeek(st,4) ※IronHSPのみ。3.7/3.8は lpoke st,4,下位 : lpoke st,8,上位
; SourceRootPath : LPWSTR (+12, 8byte) qpoke st,12,値 / qpeek(st,12) ※IronHSPのみ。3.7/3.8は lpoke st,12,下位 : lpoke st,16,上位
; SourcePath : LPWSTR (+20, 8byte) qpoke st,20,値 / qpeek(st,20) ※IronHSPのみ。3.7/3.8は lpoke st,20,下位 : lpoke st,24,上位
; SourceFilename : LPWSTR (+28, 8byte) qpoke st,28,値 / qpeek(st,28) ※IronHSPのみ。3.7/3.8は lpoke st,28,下位 : lpoke st,32,上位
; SourceDescription : LPWSTR (+36, 8byte) qpoke st,36,値 / qpeek(st,36) ※IronHSPのみ。3.7/3.8は lpoke st,36,下位 : lpoke st,40,上位
; SourceTagfile : LPWSTR (+44, 8byte) qpoke st,44,値 / qpeek(st,44) ※IronHSPのみ。3.7/3.8は lpoke st,44,下位 : lpoke st,48,上位
; TargetDirectory : LPWSTR (+52, 8byte) qpoke st,52,値 / qpeek(st,52) ※IronHSPのみ。3.7/3.8は lpoke st,52,下位 : lpoke st,56,上位
; TargetFilename : LPWSTR (+60, 8byte) qpoke st,60,値 / qpeek(st,60) ※IronHSPのみ。3.7/3.8は lpoke st,60,下位 : lpoke st,64,上位
; CopyStyle : DWORD (+68, 4byte) st.17 = 値 / 値 = st.17 (lpoke/lpeek も可)
; LayoutInf : void* (+72, 8byte) qpoke st,72,値 / qpeek(st,72) ※IronHSPのみ。3.7/3.8は lpoke st,72,下位 : lpoke st,76,上位
; SecurityDescriptor : LPWSTR (+80, 8byte) qpoke st,80,値 / qpeek(st,80) ※IronHSPのみ。3.7/3.8は lpoke st,80,下位 : lpoke st,84,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global SP_FILE_COPY_PARAMS_W, pack=1
#field int cbSize
#field intptr QueueHandle
#field intptr SourceRootPath
#field intptr SourcePath
#field intptr SourceFilename
#field intptr SourceDescription
#field intptr SourceTagfile
#field intptr TargetDirectory
#field intptr TargetFilename
#field int CopyStyle
#field intptr LayoutInf
#field intptr SecurityDescriptor
#endstruct
stdim st, SP_FILE_COPY_PARAMS_W ; NSTRUCT 変数を確保
st->cbSize = 100
mes "cbSize=" + st->cbSize