示例#1
0
 public void EnableProvider(Guid providerId, byte level, ulong anyKeyword, ulong allKeyword)
 {
     EVENT_FILTER_DESCRIPTOR filter = new EVENT_FILTER_DESCRIPTOR();
     Guid emptyGuid = Guid.Empty;
     uint status    = NativeMethods.EnableTraceEx(
         ref providerId,                // Provider GUID
         ref emptyGuid,                 // Not passing a Session ID to the provider's callback
         _handle,                       // Session handle from StartTrace
         1,                             // TRUE enables the provider
         level,                         // log all levels since we defined our levels per component
         anyKeyword,                    // To include all events that a provider provides, set MatchAnyKeyword to zero
         allKeyword,                    // No MatchAllKeyword value
         0,                             // Do not include SID or terminal session identifier in event
         ref filter                     // No provider-defined data to pass
         );
 }
示例#2
0
        public void DisableProvider(Guid providerId)
        {
            EVENT_FILTER_DESCRIPTOR filter = new EVENT_FILTER_DESCRIPTOR();
            Guid emptyGuid = Guid.Empty;
            uint status    = NativeMethods.EnableTraceEx(
                ref providerId,                // Provider GUID
                ref emptyGuid,                 // Not passing a Session ID to the provider's callback
                _handle,                       // Session handle from StartTrace
                0,                             // FALSE to disable the provider
                0xff,                          // log all levels since we defined our levels per component
                0,                             // To include all events that a provider provides, set MatchAnyKeyword to zero
                0,                             // No MatchAllKeyword value
                0,                             // Do not include SID or terminal session identifier in event
                ref filter                     // No provider-defined data to pass
                );

            if (status != NativeMethods.ERROR_NOT_FOUND &&
                status != NativeMethods.ERROR_SUCCESS)
            {
                throw new Win32Exception((int)status);
            }
        }