The CloseTrace function closes a trace.
ETW_APP_DECLSPEC_DEPRECATED ULONG WMIAPI CloseTrace( TRACEHANDLE TraceHandle );
Handle to the trace to close. The OpenTrace function returns this handle.
If the function succeeds, the return value is ERROR_SUCCESS.
If the function fails, the return value is one of the system error codes. The following table includes some common errors and their causes.
One of the following is true:
||Prior to Windows Vista, you cannot close the trace until the ProcessTrace function completes.|
||The call was successful. The ProcessTrace function will stop after it has processed all real-time events in its buffers (it will not receive any new events).|
Consumers call this function.
If you are processing events from a log file, you call this function only after the ProcessTrace function returns. However, if you are processing real-time events, you can call this function before ProcessTrace returns. If you call this function before ProcessTrace returns, the CloseTrace function returns ERROR_CTX_CLOSE_PENDING. The ERROR_CTX_CLOSE_PENDING code indicates that the CloseTrace function call was successful; the ProcessTrace function will stop processing events after it processes all events in its buffers (ProcessTrace will not receive any new events after you call the CloseTrace function). You can call the CloseTrace function from your BufferCallback, EventCallback, or EventClassCallback callback.
Prior to Windows Vista: You can call CloseTrace only after ProcessTrace returns.
For an example that uses CloseTrace, see Retrieving Event Data Using MOF.
|Minimum supported client||Windows 2000 Professional [desktop apps | UWP apps]|
|Minimum supported server||Windows 2000 Server [desktop apps | UWP apps]|
|Library||Sechost.lib on Windows 8.1 and Windows Server 2012 R2; Advapi32.lib on Windows 8, Windows Server 2012, Windows 7, Windows Server 2008 R2, Windows Server 2008, Windows Vista and Windows XP|
|DLL||Sechost.dll on Windows 8.1 and Windows Server 2012 R2; Advapi32.dll on Windows 8, Windows Server 2012, Windows 7, Windows Server 2008 R2, Windows Server 2008, Windows Vista and Windows XP|