views:

41

answers:

2

hi i want to create an application that logs these items:

  • windows turn on, turn off time
  • log in, log out time
  • hibernate time
  • restart time

in windows 7 'Admin event viewer' log most of above item but in windows xp there is not a clear log.

in addition, the user can change event setting

how i can do this with fully trust.

Thank you all friends

+2  A: 

As you observed, Windows is already logging these events and recording them in the Windows event log that you can view by using the Event Viewer.

In addition, you can write programs to read items from the event log as well as log additional events that you define.

As for security, if your users are running as normal users (Under XP, Vista or Windows 7; it doesn't matter) and not as administrative users then they will not be able to delete items from the event log.

Finally if you are on a network you can use the Event Viewer to look at the log on any of the Windows computers, not just the one you are sitting at. Similarly you can write a program that collects log data from all of the computers on the network (that are turned on) and analyze it for you.

JonnyBoats
+1 as you point out these activities are already logged and you allude to WMI when you suggest reading from Event log by writing a program to do so.
Monkieboy
Some of the events (e.g. login) are not recorded by default, but they can be added via `secpol.msc` or via Group Policy.
Richard
A: 

You need to look at WMI to hook into Windows and read the event viewer as JonnyBoats suggests:

http://www.csharphelp.com/2006/10/wmi-made-easy-for-c/

Monkieboy