SP_FILE_COPY_PARAMS_A
構造体サイズ=各フィールドのバイト数(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 | LPSTR | 8/4 | +12 | +8 | このコピーのコピー元のルート (A:\ など) を指す省略可能なポインターです。 | ||||||||||||||||||||||||||||||||
| SourcePath | LPSTR | 8/4 | +20 | +12 | ファイルが存在する場所を示す、SourceRootPath からの相対パスを指す省略可能なポインターです。 | ||||||||||||||||||||||||||||||||
| SourceFilename | LPSTR | 8/4 | +28 | +16 | コピーするファイルのファイル名部分です。 | ||||||||||||||||||||||||||||||||
| SourceDescription | LPSTR | 8/4 | +36 | +20 | ディスクの入力を求めるプロンプトで使用する、ソース メディアの説明を指す省略可能なポインターです。 | ||||||||||||||||||||||||||||||||
| SourceTagfile | LPSTR | 8/4 | +44 | +24 | SourceRootPath に存在することでソース メディアの存在を示すタグ ファイルを指す省略可能なポインターです。指定しない場合、必要に応じてファイル自体がタグ ファイルとして使用されます。 | ||||||||||||||||||||||||||||||||
| TargetDirectory | LPSTR | 8/4 | +52 | +28 | ファイルのコピー先となるディレクトリです。 | ||||||||||||||||||||||||||||||||
| TargetFilename | LPSTR | 8/4 | +60 | +32 | 対象ファイルの名前を指す省略可能なポインターです。指定しない場合、対象ファイルはコピー元のファイルと同じ名前になります。 | ||||||||||||||||||||||||||||||||
| CopyStyle | DWORD | 4 | +68 | +36 | ファイル コピー操作の動作を制御するフラグです。これらのフラグには、次の値の組み合わせを指定できます。
| ||||||||||||||||||||||||||||||||
| LayoutInf | void* | 8/4 | +72 | +40 | ソース情報の取得に使用する INF へのハンドルです。 | ||||||||||||||||||||||||||||||||
| SecurityDescriptor | LPSTR | 8/4 | +80 | +44 | ファイルに適用する ACL を指定する、省略可能なセキュリティ記述子文字列です。 |
公式ドキュメント
SP_FILE_COPY_PARAMS 構造体は、単一のファイル コピー操作を記述します。
解説(Remarks)
setupapi.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして SP_FILE_COPY_PARAMS を定義しています。エンコードに依存しないこのエイリアスの使用を、エンコードに依存するコードと混在させると、不一致が生じ、コンパイル エラーや実行時エラーの原因となる可能性があります。詳細については、「Conventions for Function Prototypes」を参照してください。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での定義
#include <windows.h>
// SP_FILE_COPY_PARAMS_A (x64 88 / x86 48 バイト)
#pragma pack(push, 1)
typedef struct SP_FILE_COPY_PARAMS_A {
DWORD cbSize;
void* QueueHandle;
LPSTR SourceRootPath;
LPSTR SourcePath;
LPSTR SourceFilename;
LPSTR SourceDescription;
LPSTR SourceTagfile;
LPSTR TargetDirectory;
LPSTR TargetFilename;
DWORD CopyStyle;
void* LayoutInf;
LPSTR SecurityDescriptor;
} SP_FILE_COPY_PARAMS_A;
#pragma pack(pop)using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct SP_FILE_COPY_PARAMS_A
{
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_A
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_A(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_A {
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_A 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_A = 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_A = 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_A {.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_A
{
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_A サイズ: 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 : LPSTR (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; SourcePath : LPSTR (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; SourceFilename : LPSTR (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; SourceDescription : LPSTR (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; SourceTagfile : LPSTR (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; TargetDirectory : LPSTR (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; TargetFilename : LPSTR (+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 : LPSTR (+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_A サイズ: 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 : LPSTR (+12, 8byte) qpoke st,12,値 / qpeek(st,12) ※IronHSPのみ。3.7/3.8は lpoke st,12,下位 : lpoke st,16,上位
; SourcePath : LPSTR (+20, 8byte) qpoke st,20,値 / qpeek(st,20) ※IronHSPのみ。3.7/3.8は lpoke st,20,下位 : lpoke st,24,上位
; SourceFilename : LPSTR (+28, 8byte) qpoke st,28,値 / qpeek(st,28) ※IronHSPのみ。3.7/3.8は lpoke st,28,下位 : lpoke st,32,上位
; SourceDescription : LPSTR (+36, 8byte) qpoke st,36,値 / qpeek(st,36) ※IronHSPのみ。3.7/3.8は lpoke st,36,下位 : lpoke st,40,上位
; SourceTagfile : LPSTR (+44, 8byte) qpoke st,44,値 / qpeek(st,44) ※IronHSPのみ。3.7/3.8は lpoke st,44,下位 : lpoke st,48,上位
; TargetDirectory : LPSTR (+52, 8byte) qpoke st,52,値 / qpeek(st,52) ※IronHSPのみ。3.7/3.8は lpoke st,52,下位 : lpoke st,56,上位
; TargetFilename : LPSTR (+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 : LPSTR (+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_A, 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_A ; NSTRUCT 変数を確保
st->cbSize = 100
mes "cbSize=" + st->cbSize