winnt.h) (ASSEMBLY_FILE_DETAILED_INFORMATION 结构

ASSEMBLY_FILE_DETAILED_INFORMATION 结构由 QueryActCtxW 函数使用。

语法

typedef struct _ASSEMBLY_FILE_DETAILED_INFORMATION {
  DWORD  ulFlags;
  DWORD  ulFilenameLength;
  DWORD  ulPathLength;
  PCWSTR lpFileName;
  PCWSTR lpFilePath;
} ASSEMBLY_FILE_DETAILED_INFORMATION, *PASSEMBLY_FILE_DETAILED_INFORMATION;

成员

ulFlags

此值始终为 0。

ulFilenameLength

lpFileName 指向的文件名的长度(以字节为单位)。 计数不包括终止 null 字符。

ulPathLength

lpFilePath 指向的路径字符串的长度(以字节为单位)。计数不包括终止 null 字符。

lpFileName

以 Null 结尾的字符串,用于指定文件的名称。

lpFilePath

以 Null 结尾的字符串,指定 lpFileName 中名为 的文件的路径。

注解

如果使用 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;
    }

要求

要求
最低受支持的客户端 Windows XP [仅限桌面应用]
最低受支持的服务器 Windows Server 2003 [仅限桌面应用]
标头 winnt.h (包括 Windows.h)