TraceLoggingRegisterEx function (traceloggingprovider.h)

Registers a TraceLogging provider so that it can be used to log events, specifying an ETW enable callback. The registration is valid until the provider is unregistered or the process exits.

Syntax

TLG_STATUS TraceLoggingRegisterEx(
  [in, out]      TraceLoggingHProvider hProvider,
  [in, optional] TLG_PENABLECALLBACK   pEnableCallback,
  [in, optional] PVOID                 pCallbackContext
);

Parameters

[in, out] hProvider

The handle of the TraceLogging provider to register. The handle must not already be registered.

[in, optional] pEnableCallback

ETW Enable Callback that will be invoked when a trace session enables or disables your provider.

[in, optional] pCallbackContext

Optional provider-defined context pointer to pass to the callback.

Return value

If you call this function from user-mode code, the function returns an HRESULT. Use the SUCCEEDED() macro to determine whether the function succeeds.

If you call this function from kernel-mode code, the function returns an NTSTATUS. Use the NT_SUCCESS() macro to determine whether the function succeeds.

Note

The error code returned by TraceLoggingRegisterEx is primarily intended for use in debugging and diagnostic scenarios. Most production code should continue to run even if an ETW provider failed to register, so release builds should usually ignore the error code returned by TraceLoggingRegisterEx.

Remarks

See TraceLoggingRegister for details on registering providers. See ETW Enable Callback for details on the callback behavior.

TraceLoggingRegisterEx does the following:

A call to TraceLoggingRegister is the same as a call to TraceLoggingRegisterEx with NULL for the callback and context parameters. Use TraceLoggingRegisterEx if you need to receive an ETW Enable Callback when sessions enable or disable your provider.

Requirements

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 traceloggingprovider.h
Library Advapi32.lib
DLL N/A

See also

ETW Enable Callback

EventRegister

TraceLoggingRegister

TraceLoggingUnregister

TraceLoggingWrite

TRACELOGGING_DEFINE_PROVIDER