title: Why isn't my Event Trace for Windows working?
body: <p>I'm trying to figure out how to use Event Tracing for Windows... but I'm failing.<br>
  Why does this code give me the error code <code>ERROR_WMI_INSTANCE_NOT_FOUND</code>?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;tchar.h&gt;
  #include &lt;Windows.h&gt;
  #include &lt;Wmistr.h&gt;
  #include &lt;Evntrace.h&gt;
  #include &lt;evntcons.h&gt;
  
  ULONG NTAPI EtpEtwBufferCallback(IN PEVENT_TRACE_LOGFILE Buffer) { return TRUE; }
  VOID  NTAPI  EtpEtwEventCallback(IN PEVENT_TRACE EventTrace) { }
  
  int _tmain()
  {
      LPCTSTR loggerName = KERNEL_LOGGER_NAME;
      EVENT_TRACE_LOGFILE logFile = {0};
      logFile.LoggerName = const_cast&lt;LPTSTR&gt;(loggerName);
      logFile.ProcessTraceMode = PROCESS_TRACE_MODE_REAL_TIME;
      logFile.BufferCallback = EtpEtwBufferCallback;
      logFile.EventCallback = EtpEtwEventCallback;
      TRACEHANDLE hTrace = OpenTrace(&amp;logFile);
      ULONG result = ProcessTrace(&amp;hTrace, 1, NULL, NULL);
      // result is ERROR_WMI_INSTANCE_NOT_FOUND
      _tprintf(_T("%u\n"), result);
  }
  </code></pre>