ホーム › System.ApplicationInstallationAndServicing › ASSEMBLY_FILE_DETAILED_INFORMATION
ASSEMBLY_FILE_DETAILED_INFORMATION
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| ulFlags | DWORD | 4 | +0 | +0 | この値は常に 0 です。 |
| ulFilenameLength | DWORD | 4 | +4 | +4 | lpFileName が指すファイル名の長さ (バイト単位)。この長さには終端の null 文字は含まれません。 |
| ulPathLength | DWORD | 4 | +8 | +8 | lpFilePath が指すパス文字列の長さ (バイト単位)。この長さには終端の null 文字は含まれません。 |
| lpFileName | LPWSTR | 8/4 | +16 | +12 | ファイルの名前を指定する、null で終わる文字列です。 |
| lpFilePath | LPWSTR | 8/4 | +24 | +16 | lpFileName で指定されたファイルへのパスを指定する、null で終わる文字列です。 |
公式ドキュメント
ASSEMBLY_FILE_DETAILED_INFORMATION 構造体は、 QueryActCtxW 関数で使用されます。
解説(Remarks)
FileInformationInAssemblyOfAssemblyInActivationContext オプションを指定して QueryActCtxW を呼び出し、関数が成功した場合、返されるバッファー内の情報は ASSEMBLY_FILE_DETAILED_INFORMATION 構造体の形式になります。次に、アクティベーション コンテキストの詳細情報を保持するために使用する構造体と、 QueryActCtxW の呼び出しの例を示します。
PASSEMBLY_FILE_DETAILED_INFORMATION pAssemblyInfo = NULL;
ACTIVATION_CONTEXT_QUERY_INDEX QueryIndex;
BOOL fSuccess = FALSE;
SIZE_T cbRequired;
HANDLE hActCtx = INVALID_HANDLE_VALUE;
BYTE bTemporaryBuffer[512];
PVOID pvDataBuffer = (PVOID)bTemporaryBuffer;
SIZE_T cbAvailable = sizeof(bTemporaryBuffer);
// Request the first file in the root assembly
QueryIndex.ulAssemblyIndex = 1;
QueryIndex.ulFileIndexInAssembly = 0;
if (GetCurrentActCtx(&hActCtx)) {
// Attempt to use our stack-based buffer first - if that's not large
// enough, allocate from the heap and try again.
fSuccess = QueryActCtxW(
0,
hActCtx,
(PVOID)&QueryIndex,
FileInformationInAssemblyOfAssemblyInActivationContext,
pvDataBuffer,
cbAvailable,
&cbRequired);
// Failed, because the buffer was too small.
if (!fSuccess && (GetLastError() == ERROR_INSUFFICIENT_BUFFER)) {
// Allocate what we need from the heap - fail if there isn't enough
// memory to do so.
pvDataBuffer = HeapAlloc(GetProcessHeap(), 0, cbRequired);
if (pvDataBuffer == NULL) {
fSuccess = FALSE;
goto DoneQuerying;
}
cbAvailable = cbRequired;
// If this fails again, exit out.
fSuccess = QueryActCtxW(
0,
hActCtx,
(PVOID)&QueryIndex,
FileInformationInAssemblyOfAssemblyInActivationContext,
pvDataBuffer,
cbAvailable,
&cbRequired);
}
if (fSuccess) {
// Now that we've found the assembly info, cast our target buffer back to
// the assembly info pointer. Use pAssemblyInfo->lpFileName
pAssemblyInfo = (PASSEMBLY_FILE_DETAILED_INFORMATION)pvDataBuffer;
}
}
DoneQuerying:
if (hActCtx != INVALID_HANDLE_VALUE)
ReleaseActCtx(hActCtx);
if (pvDataBuffer && (pvDataBuffer != bTemporaryBuffer)) {
HeapFree(GetProcessHeap(), 0, pvDataBuffer);
pvDataBuffer = 0;
}
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での定義
#include <windows.h>
// ASSEMBLY_FILE_DETAILED_INFORMATION (x64 32 / x86 20 バイト)
typedef struct ASSEMBLY_FILE_DETAILED_INFORMATION {
DWORD ulFlags;
DWORD ulFilenameLength;
DWORD ulPathLength;
LPWSTR lpFileName;
LPWSTR lpFilePath;
} ASSEMBLY_FILE_DETAILED_INFORMATION;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct ASSEMBLY_FILE_DETAILED_INFORMATION
{
public uint ulFlags;
public uint ulFilenameLength;
public uint ulPathLength;
public IntPtr lpFileName;
public IntPtr lpFilePath;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure ASSEMBLY_FILE_DETAILED_INFORMATION
Public ulFlags As UInteger
Public ulFilenameLength As UInteger
Public ulPathLength As UInteger
Public lpFileName As IntPtr
Public lpFilePath As IntPtr
End Structureimport ctypes
from ctypes import wintypes
class ASSEMBLY_FILE_DETAILED_INFORMATION(ctypes.Structure):
_fields_ = [
("ulFlags", wintypes.DWORD),
("ulFilenameLength", wintypes.DWORD),
("ulPathLength", wintypes.DWORD),
("lpFileName", ctypes.c_void_p),
("lpFilePath", ctypes.c_void_p),
]#[repr(C)]
pub struct ASSEMBLY_FILE_DETAILED_INFORMATION {
pub ulFlags: u32,
pub ulFilenameLength: u32,
pub ulPathLength: u32,
pub lpFileName: *mut core::ffi::c_void,
pub lpFilePath: *mut core::ffi::c_void,
}import "golang.org/x/sys/windows"
type ASSEMBLY_FILE_DETAILED_INFORMATION struct {
ulFlags uint32
ulFilenameLength uint32
ulPathLength uint32
lpFileName uintptr
lpFilePath uintptr
}type
ASSEMBLY_FILE_DETAILED_INFORMATION = record
ulFlags: DWORD;
ulFilenameLength: DWORD;
ulPathLength: DWORD;
lpFileName: Pointer;
lpFilePath: Pointer;
end;const ASSEMBLY_FILE_DETAILED_INFORMATION = extern struct {
ulFlags: u32,
ulFilenameLength: u32,
ulPathLength: u32,
lpFileName: ?*anyopaque,
lpFilePath: ?*anyopaque,
};type
ASSEMBLY_FILE_DETAILED_INFORMATION {.bycopy.} = object
ulFlags: uint32
ulFilenameLength: uint32
ulPathLength: uint32
lpFileName: pointer
lpFilePath: pointerstruct ASSEMBLY_FILE_DETAILED_INFORMATION
{
uint ulFlags;
uint ulFilenameLength;
uint ulPathLength;
void* lpFileName;
void* lpFilePath;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; ASSEMBLY_FILE_DETAILED_INFORMATION サイズ: 20 バイト(x86)
dim st, 5 ; 4byte整数×5(構造体サイズ 20 / 4 切り上げ)
; ulFlags : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; ulFilenameLength : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; ulPathLength : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; lpFileName : LPWSTR (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; lpFilePath : LPWSTR (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; ASSEMBLY_FILE_DETAILED_INFORMATION サイズ: 32 バイト(x64)
dim st, 8 ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; ulFlags : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; ulFilenameLength : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; ulPathLength : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; lpFileName : LPWSTR (+16, 8byte) qpoke st,16,値 / qpeek(st,16) ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; lpFilePath : LPWSTR (+24, 8byte) qpoke st,24,値 / qpeek(st,24) ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global ASSEMBLY_FILE_DETAILED_INFORMATION
#field int ulFlags
#field int ulFilenameLength
#field int ulPathLength
#field intptr lpFileName
#field intptr lpFilePath
#endstruct
stdim st, ASSEMBLY_FILE_DETAILED_INFORMATION ; NSTRUCT 変数を確保
st->ulFlags = 100
mes "ulFlags=" + st->ulFlags