2

I want to write logs in Event viewer under "Applications and Services logs"section using c++. But I cannot find any interface about it, Does anybody know?

I have tried "RegisterEventSource", "ReportEvent", but i can only write event viewer logs in Applications but not under Applications and Services logs.

I also find some samples in C#, but my application is in C++.

Thanks.

1 Answers1

1

You can have a look at the EventWrite function. It is contained in the evntprov.h. This allows you to write a specific entry to a Register Handle. By using EventRegister you can create a Register Handle. Remember to call EventUnregsiter when you are done with the Register Handle.

I have unfortunately not worked with this in quite a while. Have a read over at Windows Docs about evntprov.h and all its functionality. I am sure it will point you in the correct direction.

0x436f72647265
  • 414
  • 2
  • 8
  • 21
  • Thanks for your help. Do you know where to find the log written by EventWrite, I cannot find them at Event Viewer. Thanks. – BensonZheng May 17 '19 at 07:23
  • No problem. I can't remember the exact working of these functions. As far as I remember it depends on the Event Register. But give the Windows Doc a read. – 0x436f72647265 May 19 '19 at 10:17
  • You can launch a tracing session with an ETW consumer like XPerf.exe, configuring it to capture your specific guid. – morallo Jun 23 '20 at 23:05