Applies to: desktop apps | Metro style apps
Begins one-time initialization.
Syntax
BOOL WINAPI InitOnceBeginInitialize( __inout LPINIT_ONCE lpInitOnce, __in DWORD dwFlags, __out PBOOL fPending, __out_opt LPVOID *lpContext );
Parameters
- lpInitOnce [in, out]
-
A pointer to the one-time initialization structure.
- dwFlags [in]
-
This parameter can be one or more of the following flags.
- fPending [out]
-
If the function succeeds, this parameter indicates the current initialization status.
If this parameter is TRUE and dwFlags contains INIT_ONCE_CHECK_ONLY, the initialization is pending and the context data is invalid.
If this parameter is FALSE, initialization has already completed and the caller can retrieve the context data from the lpContext parameter.
If this parameter is TRUE and dwFlags does not contain INIT_ONCE_CHECK_ONLY, initialization has been started and the caller can perform the initialization tasks.
- lpContext [out, optional]
-
An optional parameter that receives the data stored with the one-time initialization structure upon success. The low-order INIT_ONCE_CTX_RESERVED_BITS bits of the data are always zero.
Return value
If INIT_ONCE_CHECK_ONLY is not specified and the function succeeds, the return value is TRUE.
If INIT_ONCE_CHECK_ONLY is specified and initialization has completed, the return value is TRUE.
Otherwise, the return value is FALSE. To get extended error information, call GetLastError.
Remarks
This function can be used for either synchronous or asynchronous one-time initialization. For asynchronous one-time initialization, use the INIT_ONCE_ASYNC flag. To specify a callback function to execute during synchronous one-time initialization, see the InitOnceExecuteOnce function.
If this function succeeds, the thread can create a synchronization object and specify in the lpContext parameter of the InitOnceComplete function.
To compile an application that uses this function, define _WIN32_WINNT as 0x0600 or later. For more information, see Using the Windows Headers.
Examples
For an example that uses this function, see Using One-Time Initialization.
Requirements
|
Minimum supported client | Windows Vista |
|---|---|
|
Minimum supported server | Windows Server 2008 |
|
Header |
|
|
Library |
|
|
DLL |
|
See also
Send comments about this topic to Microsoft
Build date: 3/7/2012