InitOnceComplete function (synchapi.h)

Completes one-time initialization started with the InitOnceBeginInitialize function.


BOOL InitOnceComplete(
  [in, out]      LPINIT_ONCE lpInitOnce,
  [in]           DWORD       dwFlags,
  [in, optional] LPVOID      lpContext


[in, out] lpInitOnce

A pointer to the one-time initialization structure.

[in] dwFlags

This parameter can be one of the following flags.

Value Meaning
Operate in asynchronous mode. This enables multiple completion attempts to execute in parallel. This flag must match the flag passed in the corresponding call to the InitOnceBeginInitialize function. This flag may not be combined with INIT_ONCE_INIT_FAILED.
The initialization attempt failed. This flag may not be combined with INIT_ONCE_ASYNC. To fail an asynchronous initialization, merely abandon it (that is, do not call the InitOnceComplete function).

[in, optional] lpContext

A pointer to the data to be stored with the one-time initialization structure. This data is returned in the lpContext parameter passed to subsequent calls to the InitOnceBeginInitialize function. If lpContext points to a value, the low-order INIT_ONCE_CTX_RESERVED_BITS of the value must be zero. If lpContext points to a data structure, the data structure must be DWORD-aligned.

Return value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.


To compile an application that uses this function, define _WIN32_WINNT as 0x0600 or later. For more information, see Using the Windows Headers.


For an example that uses this function, see Using One-Time Initialization.


Requirement Value
Minimum supported client Windows Vista [desktop apps | UWP apps]
Minimum supported server Windows Server 2008 [desktop apps | UWP apps]
Target Platform Windows
Header synchapi.h (include Windows.h on Windows 7, Windows Server 2008 Windows Server 2008 R2)
Library Kernel32.lib
DLL Kernel32.dll

See also


One-Time Initialization

Synchronization Functions