Share via


ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION-Struktur (winnt.h)

Die ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION-Struktur wird von der QueryActCtxW-Funktion verwendet.

Syntax

typedef struct _ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION {
  DWORD                         ElementCount;
  COMPATIBILITY_CONTEXT_ELEMENT Elements[];
} ACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION, *PACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION;

Member

ElementCount

Die Anzahl der im Anwendungsmanifest definierten Kompatibilitätselemente.

Elements

Dies ist ein Array von COMPATIBILITY_CONTEXT_ELEMENT Strukturen. Jede Struktur beschreibt ein Kompatibilitätselement im Anwendungsmanifest.

Hinweise

Das folgende Beispiel erfordert Windows Server 2008 R2 oder Windows 7 und zeigt die Methode zum Abrufen von Informationen zum Kompatibilitätskontext.

HANDLE   ActCtxHandle=INVALID_HANDLE_VALUE;
SIZE_T   BytesWritten=0;
PACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION CtxCompatInfo=NULL;

// Query the compatibility information size
bReturn = QueryActCtxW(0, 
                       ActCtxHandle,
                       NULL,
                       CompatibilityInformationInActivationContext,
                       NULL,
                       0,
                       &BytesWritten);

if (bReturn == FALSE && GetLastError() !=ERROR_INSUFFICIENT_BUFFER)
       {
	 goto EXIT;
	 }
	 
CtxCompatInfo = 
(PACTIVATION_CONTEXT_COMPATIBILITY_INFORMATION)HeapAlloc(GetProcessHeap(), 
    HEAP_ZERO_MEMORY, BytesWritten);

if (CtxCompatInfo==NULL)
       {
	 // Out of memory
	 goto EXIT;
	 }

// Query the compatibility information
bReturn = QueryActCtxW(0,
                       ActCtxHandle,
                       NULL,
                       CompatibilityInformationInActivationContext,
                       CtxCompatInfo,
                       BytesWritten,
                       &BytesWritten);

if (bReturn==FALSE)
       {
        // Unexpected error: use GetLastError() to check
        goto EXIT;
	 }

for (DWORD ElementIndex=0; ElementIndex < CtxCompatInfo->ElementCount; ElementIndex ++)
{
PCOMPATIBILITY_CONTEXT_ELEMENT ContextElement = &CtxCompatInfo->Elements[ElementIndex];
if (ContextElement->Type == ACTCTX_COMPATIBILITY_ELEMENT_TYPE_OS)
       {
       if (memcmp(&ContextElement->Id, &WIN7_CONTEXT_GUID, sizeof (GUID))==0)
             {printf_s("Windows 7 is supported");}
	 }
}
	 
EXIT:
if (ActCtxHandle != INVALID_HANDLE_VALUE) 
       {
        ReleaseActCtx (ActCtxHandle)
	 }
if (CtxCompatInfo != NULL)
       {
        RtlFreeHeap (RtlProcessHeap (), 0, CtxCompatInfo);
        CtxCompatInfo = NULL;
	 }

Anforderungen

   
Unterstützte Mindestversion (Client) Windows 7 [nur Desktop-Apps]
Unterstützte Mindestversion (Server) Windows Server 2008 R2 [nur Desktop-Apps]
Kopfzeile winnt.h (Einschließen von Windows.h)