The documentation for
If the function fails, the return value is zero. To get extended error information, call GetLastError.
On the other hand, the documentation for the
If the function returns FALSE, the block is not marked as initialized and the call to InitOnceExecuteOnce fails. To communicate additional error information, call SetLastError. before returning FALSE.
The second paragraph implies that
does not itself call
because if it did,
then that would wipe out
the value set by the callback.
Is that really the case?
Yes, that's really the case.
The remark in the first paragraph about calling
that your callback uses
GetLastError to report
why it wasn't able to initialize.
I agree, however, that the documentation is misleading here.
But if your callback wants to return status information more complex than a single "success/failed", you are probably better served by the synchronous two-phase initialization pattern, which makes it a lot easier to return more complex information. You can even use it to throw a C++ exception.