create a windows logger
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
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.
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/
精彩评论