ActivateActCtx Function

The ActivateActCtx function activates the specified activation context. It does this by pushing the specified activation context to the top of the activation stack. The specified activation context is thus associated with the current thread and any appropriate side-by-side API functions.

Syntax

C++
BOOL ActivateActCtx(
  __in   HANDLE hActCtx,
  __out  ULONG_PTR *lpCookie
);

Parameters

hActCtx [in]

Handle to an ACTCTX structure that contains information on the activation context that is to be made active.

lpCookie [out]

Pointer to a ULONG_PTR that functions as a cookie, uniquely identifying a specific, activated activation context.

Return Value

If the function succeeds, it returns TRUE. Otherwise, it returns FALSE.

This function sets errors that can be retrieved by calling GetLastError. For an example, see Retrieving the Last-Error Code. For a complete list of error codes, see System Error Codes.

Remarks

The lpCookie parameter is later passed to DeactivateActCtx, which verifies the pairing of calls to ActivateActCtx and DeactivateActCtx and ensures that the appropriate activation context is being deactivated. This is done because the deactivation of activation contexts must occur in the reverse order of activation.

The activation of activation contexts can be understood as pushing an activation context onto a stack of activation contexts. The activation context you activate through this function redirects any binding to DLLs, window classes, COM servers, type libraries, and mutexes for any side-by-side APIs you call.

The top item of an activation context stack is the active, default-activation context of the current thread. If a null activation context handle is pushed onto the stack, thereby activating it, the default settings in the original manifest override all activation contexts that are lower on the stack.

Requirements

Minimum supported clientWindows XP
Minimum supported serverWindows Server 2003
HeaderWinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll

See Also

DeactivateActCtx
ACTCTX

Send comments about this topic to Microsoft

Build date: 11/12/2009

Tags :


Community Content

dmex
vb.net syntax
<DllImport("kernel32.dll")> Public Shared Function ActivateActCtx(ByVal hActCtx As IntPtr, <Out> ByRef lpCookie As IntPtr) As Boolean
End Function
Tags :

dmex
C# syntax
[DllImport("kernel32.dll")]
private static extern bool ActivateActCtx(IntPtr hActCtx, out IntPtr lpCookie);
Tags :

Page view tracker