Using Tracing

[This is preliminary documentation and subject to change.]

Each application or service component calls TraceRegister() to obtain an identifier (ID) to use in calls to the output functions. On this call, the DLL reads configuration information for the caller from the registry, and sets up the console or file to which output will be sent. In addition, a critical section is created that will be used to synchronize calls to the tracing DLL functions by the registering component's threads. An event is associated with the registry key for the caller, so that changes to the tracing parameters for the caller can be handled dynamically.

After registering, the application may call the output functions, passing the ID returned by TraceRegister(). When the application no longer requires the tracing DLL's support, it should call TraceDeregister() so that handles associated with it can be closed.

There are two versions of each output function. One version prefixes the output it generates with standard information such as the name associated with the caller, the thread ID of the caller, and the current time. The other version allows the caller to omit the standard information normally generated. For instance, TracePrintf() includes standard information, but TracePrintfEx() does not, unless the flag passed to it specifies that it should.

Support for Unicode clients is built into the tracing DLL. All that is required is that the client define the constant UNICODE before including the header containing definitions for the tracing DLL functions.