Skip to main content
EventWriteTransfer function

Links events together when tracing events in an end-to-end scenario.


ULONG EventWriteTransfer(
  _In_     REGHANDLE              RegHandle,
  _In_     PCEVENT_DESCRIPTOR     EventDescriptor,
  _In_opt_ LPCGUID                ActivityId,
  _In_opt_ LPCGUID                RelatedActivityId,
  _In_     ULONG                  UserDataCount,


RegHandle [in]

Registration handle of the provider. The handle comes from EventRegister.

EventDescriptor [in]

Metadata that identifies the event to write. For details, see EVENT_DESCRIPTOR.

ActivityId [in, optional]

GUID that uniquely identifies this activity. If NULL, ETW gets the identifier from the thread local storage. For details on getting this identifier, see EventActivityIdControl.

RelatedActivityId [in, optional]

Activity identifier from the previous component. Use this parameter to link your component's events to the previous component's events. To get the activity identifier that was set for the previous component, see the descriptions for the ControlCode parameter of the EventActivityIdControl function.

UserDataCount [in]

Number of EVENT_DATA_DESCRIPTOR structures in UserData. The maximum number is 128.

UserData [in, optional]

The event data to write. Allocate a block of memory that contains one or more EVENT_DATA_DESCRIPTOR structures. Set this parameter to NULL if UserDataCount is zero. The data must be in the order specified in the manifest.

Return value

Returns ERROR_SUCCESS if successful or one of the following values on error.

Return codeDescription

One or more of the parameters is not valid.


The registration handle of the provider is not valid.


The event size is larger than the allowed maximum (64k - header).


The session buffer size is too small for the event.


Occurs when filled buffers are trying to flush to disk, but disk IOs are not happening fast enough. This happens when the disk is slow and event traffic is heavy. Eventually, there are no more free (empty) buffers and the event is dropped.


The real-time playback file is full. Events are not logged to the session until a real-time consumer consumes the events from the playback file. Do not stop logging events based on this error code.



Beginning with Windows 7 and Windows Server 2008 R2, use EventWriteEx to write transfer events in an end-to-end scenario.

Use this function when several components want to relate their events in an end-to-end tracing scenario. For example, components A, B, and C perform work on a related activity and want to link their events so that a consumer can consume all the events related to that activity. ETW uses thread local storage to make available to the next component the previous component's activity identifier. The component retrieves from the local storage the previous component's identifier and sets the related activity identifier to it. The consumer can then use the related activity identifier to walk the chain of the events from one component to the next.

If each component defined their own activity identifier, the components can make the following calls to link the events:

  • Call the EventActivityIdControl function using the EVENT_ACTIVITY_CTRL_GET_SET_ID control code. The function uses your identifier to set the activity identifier in the thread local storage and returns the activity identifier for the previous component, if set.
  • Set the RelatedActivityId parameter of this function to the ActivityId value that the EventActivityIdControl function returned. Note that for the first component, the related identifier will be all zeros (GUID_NULL).
  • Set the ActivityId of this function to NULL to use the activity identifier that you set in thread local storage.

Event data written with this function requires a manifest. Since the manifest is embedded in the provider, the provider must be available for a consumer to consume the data written by the provider.

ETW decides based on the event descriptor if the event is written to a session (for details, see EnableTraceEx).


Minimum supported client

Windows Vista [desktop apps | UWP apps]

Minimum supported server

Windows Server 2008 [desktop apps | UWP apps]

Minimum supported phone

Windows Phone 8.1







See also