Win32 API 日本語リファレンス
ホームSystem.ApplicationInstallationAndServicing › ACTIVATION_CONTEXT_DETAILED_INFORMATION

ACTIVATION_CONTEXT_DETAILED_INFORMATION

構造体
サイズx64: 64 バイト / x86: 48 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
dwFlagsDWORD4+0+0この値は常に 0 です。
ulFormatVersionDWORD4+4+4この値は、返される情報の形式を指定します。Windows XP および Windows Server 2003 では、このメンバーは常に 1 です。
ulAssemblyCountDWORD4+8+8アクティブ化コンテキスト内のアセンブリの数。
ulRootManifestPathTypeDWORD4+12+12

このアセンブリのマニフェストが読み込まれたパスの種類を指定します。

このメンバーは、常に次の定数のいずれかです。

ulRootManifestPathCharsDWORD4+16+16マニフェストのパスの文字数。
ulRootConfigurationPathTypeDWORD4+20+20

このアセンブリのアプリケーション構成マニフェストが読み込まれたパスの種類を指定します。

このメンバーは、常に次の定数のいずれかです。

ulRootConfigurationPathCharsDWORD4+24+24アプリケーション構成ファイルのパスの文字数。
ulAppDirPathTypeDWORD4+28+28

このアプリケーション マニフェストが読み込まれたパスの種類を指定します。

このメンバーは、常に次の定数のいずれかです。

ulAppDirPathCharsDWORD4+32+32アプリケーション ディレクトリの文字数。
lpRootManifestPathLPWSTR8/4+40+36アプリケーション マニフェストのパス。
lpRootConfigurationPathLPWSTR8/4+48+40構成ファイルのパス。
lpAppDirPathLPWSTR8/4+56+44アプリケーション ディレクトリのパス。

公式ドキュメント

ACTIVATION_CONTEXT_DETAILED_INFORMATION 構造体は、 QueryActCtxW 関数によって使用されます。

解説(Remarks)

QueryActCtxW を ActivationContextDetailedInformation オプションで呼び出して関数が成功した場合、返されるバッファー内の情報は ACTIVATION_CONTEXT_DETAILED_INFORMATION 構造体の形式になります。次に示すのは、アクティブ化コンテキストの詳細情報を保持するために使用する構造体と、 QueryActCtxW の呼び出しの例です。

PACTIVATION_CONTEXT_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, 
        AssemblyDetailedInformationInActivationContext,
        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,
            AssemblyDetailedInformationInActivationContext,
            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 = (PACTIVATION_CONTEXT_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)

各言語での定義

#include <windows.h>

// ACTIVATION_CONTEXT_DETAILED_INFORMATION  (x64 64 / x86 48 バイト)
typedef struct ACTIVATION_CONTEXT_DETAILED_INFORMATION {
    DWORD dwFlags;
    DWORD ulFormatVersion;
    DWORD ulAssemblyCount;
    DWORD ulRootManifestPathType;
    DWORD ulRootManifestPathChars;
    DWORD ulRootConfigurationPathType;
    DWORD ulRootConfigurationPathChars;
    DWORD ulAppDirPathType;
    DWORD ulAppDirPathChars;
    LPWSTR lpRootManifestPath;
    LPWSTR lpRootConfigurationPath;
    LPWSTR lpAppDirPath;
} ACTIVATION_CONTEXT_DETAILED_INFORMATION;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct ACTIVATION_CONTEXT_DETAILED_INFORMATION
{
    public uint dwFlags;
    public uint ulFormatVersion;
    public uint ulAssemblyCount;
    public uint ulRootManifestPathType;
    public uint ulRootManifestPathChars;
    public uint ulRootConfigurationPathType;
    public uint ulRootConfigurationPathChars;
    public uint ulAppDirPathType;
    public uint ulAppDirPathChars;
    public IntPtr lpRootManifestPath;
    public IntPtr lpRootConfigurationPath;
    public IntPtr lpAppDirPath;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure ACTIVATION_CONTEXT_DETAILED_INFORMATION
    Public dwFlags As UInteger
    Public ulFormatVersion As UInteger
    Public ulAssemblyCount As UInteger
    Public ulRootManifestPathType As UInteger
    Public ulRootManifestPathChars As UInteger
    Public ulRootConfigurationPathType As UInteger
    Public ulRootConfigurationPathChars As UInteger
    Public ulAppDirPathType As UInteger
    Public ulAppDirPathChars As UInteger
    Public lpRootManifestPath As IntPtr
    Public lpRootConfigurationPath As IntPtr
    Public lpAppDirPath As IntPtr
End Structure
import ctypes
from ctypes import wintypes

class ACTIVATION_CONTEXT_DETAILED_INFORMATION(ctypes.Structure):
    _fields_ = [
        ("dwFlags", wintypes.DWORD),
        ("ulFormatVersion", wintypes.DWORD),
        ("ulAssemblyCount", wintypes.DWORD),
        ("ulRootManifestPathType", wintypes.DWORD),
        ("ulRootManifestPathChars", wintypes.DWORD),
        ("ulRootConfigurationPathType", wintypes.DWORD),
        ("ulRootConfigurationPathChars", wintypes.DWORD),
        ("ulAppDirPathType", wintypes.DWORD),
        ("ulAppDirPathChars", wintypes.DWORD),
        ("lpRootManifestPath", ctypes.c_void_p),
        ("lpRootConfigurationPath", ctypes.c_void_p),
        ("lpAppDirPath", ctypes.c_void_p),
    ]
#[repr(C)]
pub struct ACTIVATION_CONTEXT_DETAILED_INFORMATION {
    pub dwFlags: u32,
    pub ulFormatVersion: u32,
    pub ulAssemblyCount: u32,
    pub ulRootManifestPathType: u32,
    pub ulRootManifestPathChars: u32,
    pub ulRootConfigurationPathType: u32,
    pub ulRootConfigurationPathChars: u32,
    pub ulAppDirPathType: u32,
    pub ulAppDirPathChars: u32,
    pub lpRootManifestPath: *mut core::ffi::c_void,
    pub lpRootConfigurationPath: *mut core::ffi::c_void,
    pub lpAppDirPath: *mut core::ffi::c_void,
}
import "golang.org/x/sys/windows"

type ACTIVATION_CONTEXT_DETAILED_INFORMATION struct {
	dwFlags uint32
	ulFormatVersion uint32
	ulAssemblyCount uint32
	ulRootManifestPathType uint32
	ulRootManifestPathChars uint32
	ulRootConfigurationPathType uint32
	ulRootConfigurationPathChars uint32
	ulAppDirPathType uint32
	ulAppDirPathChars uint32
	lpRootManifestPath uintptr
	lpRootConfigurationPath uintptr
	lpAppDirPath uintptr
}
type
  ACTIVATION_CONTEXT_DETAILED_INFORMATION = record
    dwFlags: DWORD;
    ulFormatVersion: DWORD;
    ulAssemblyCount: DWORD;
    ulRootManifestPathType: DWORD;
    ulRootManifestPathChars: DWORD;
    ulRootConfigurationPathType: DWORD;
    ulRootConfigurationPathChars: DWORD;
    ulAppDirPathType: DWORD;
    ulAppDirPathChars: DWORD;
    lpRootManifestPath: Pointer;
    lpRootConfigurationPath: Pointer;
    lpAppDirPath: Pointer;
  end;
const ACTIVATION_CONTEXT_DETAILED_INFORMATION = extern struct {
    dwFlags: u32,
    ulFormatVersion: u32,
    ulAssemblyCount: u32,
    ulRootManifestPathType: u32,
    ulRootManifestPathChars: u32,
    ulRootConfigurationPathType: u32,
    ulRootConfigurationPathChars: u32,
    ulAppDirPathType: u32,
    ulAppDirPathChars: u32,
    lpRootManifestPath: ?*anyopaque,
    lpRootConfigurationPath: ?*anyopaque,
    lpAppDirPath: ?*anyopaque,
};
type
  ACTIVATION_CONTEXT_DETAILED_INFORMATION {.bycopy.} = object
    dwFlags: uint32
    ulFormatVersion: uint32
    ulAssemblyCount: uint32
    ulRootManifestPathType: uint32
    ulRootManifestPathChars: uint32
    ulRootConfigurationPathType: uint32
    ulRootConfigurationPathChars: uint32
    ulAppDirPathType: uint32
    ulAppDirPathChars: uint32
    lpRootManifestPath: pointer
    lpRootConfigurationPath: pointer
    lpAppDirPath: pointer
struct ACTIVATION_CONTEXT_DETAILED_INFORMATION
{
    uint dwFlags;
    uint ulFormatVersion;
    uint ulAssemblyCount;
    uint ulRootManifestPathType;
    uint ulRootManifestPathChars;
    uint ulRootConfigurationPathType;
    uint ulRootConfigurationPathChars;
    uint ulAppDirPathType;
    uint ulAppDirPathChars;
    void* lpRootManifestPath;
    void* lpRootConfigurationPath;
    void* lpAppDirPath;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; ACTIVATION_CONTEXT_DETAILED_INFORMATION サイズ: 48 バイト(x86)
dim st, 12    ; 4byte整数×12(構造体サイズ 48 / 4 切り上げ)
; dwFlags : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; ulFormatVersion : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; ulAssemblyCount : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; ulRootManifestPathType : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; ulRootManifestPathChars : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; ulRootConfigurationPathType : DWORD (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; ulRootConfigurationPathChars : DWORD (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; ulAppDirPathType : DWORD (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; ulAppDirPathChars : DWORD (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; lpRootManifestPath : LPWSTR (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; lpRootConfigurationPath : LPWSTR (+40, 4byte)  st.10 = 値  /  値 = st.10   (lpoke/lpeek も可)
; lpAppDirPath : LPWSTR (+44, 4byte)  st.11 = 値  /  値 = st.11   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; ACTIVATION_CONTEXT_DETAILED_INFORMATION サイズ: 64 バイト(x64)
dim st, 16    ; 4byte整数×16(構造体サイズ 64 / 4 切り上げ)
; dwFlags : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; ulFormatVersion : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; ulAssemblyCount : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; ulRootManifestPathType : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; ulRootManifestPathChars : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; ulRootConfigurationPathType : DWORD (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; ulRootConfigurationPathChars : DWORD (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; ulAppDirPathType : DWORD (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; ulAppDirPathChars : DWORD (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; lpRootManifestPath : LPWSTR (+40, 8byte)  qpoke st,40,値 / qpeek(st,40)  ※IronHSPのみ。3.7/3.8は lpoke st,40,下位 : lpoke st,44,上位
; lpRootConfigurationPath : LPWSTR (+48, 8byte)  qpoke st,48,値 / qpeek(st,48)  ※IronHSPのみ。3.7/3.8は lpoke st,48,下位 : lpoke st,52,上位
; lpAppDirPath : LPWSTR (+56, 8byte)  qpoke st,56,値 / qpeek(st,56)  ※IronHSPのみ。3.7/3.8は lpoke st,56,下位 : lpoke st,60,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global ACTIVATION_CONTEXT_DETAILED_INFORMATION
    #field int dwFlags
    #field int ulFormatVersion
    #field int ulAssemblyCount
    #field int ulRootManifestPathType
    #field int ulRootManifestPathChars
    #field int ulRootConfigurationPathType
    #field int ulRootConfigurationPathChars
    #field int ulAppDirPathType
    #field int ulAppDirPathChars
    #field intptr lpRootManifestPath
    #field intptr lpRootConfigurationPath
    #field intptr lpAppDirPath
#endstruct

stdim st, ACTIVATION_CONTEXT_DETAILED_INFORMATION        ; NSTRUCT 変数を確保
st->dwFlags = 100
mes "dwFlags=" + st->dwFlags