Solved

Reading from the NT Event Log

Posted on 1998-10-05
5
175 Views
Last Modified: 2011-10-03
I need to read entries from the NT Event Log automatically, specifically from the SYSTEM log, and then delet the entry. Can anyone point me in the right direction (and code would be sweet)
0
Comment
Question by:purphaze
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 

Author Comment

by:purphaze
ID: 1438280
Edited text of question
0
 
LVL 4

Expert Comment

by:mcix
ID: 1438281
In the Win32 API, there is a function called ReadEventLog that can be used to read the event log.

If no one else can solve this for you, I will write a little VB code that can call it for you.
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1438282
Goto http://www.netfokus.dk/vbadmincode/
and follow the link Code
There are 2 samples to download
one to read and one to write to the event log
0
 

Author Comment

by:purphaze
ID: 1438283
I downloaded the code, and worked with it for a few days, but it keeps coming up with errors (I do not know if its compatible with VB6, which is what I am using.) The answer from MCIX is a good startng point, and I am going to try to get a better understanding of using the Win32 API.
0
 
LVL 2

Accepted Solution

by:
Poddy earned 50 total points
ID: 1438284
you can't delete individual items from the Event Log.
You must either clear the log completely, or leave it

These are the functions you need to use to read the event log

Private Declare Function OpenEventLogNT Lib "advapi32.dll" Alias "OpenEventLogA" (ByVal lpUNCServerName As String, ByVal lpSourceName As String) As Long

Private Declare Function GetNumberOfEventLogRecordsNT Lib "advapi32.dll" Alias "GetNumberOfEventLogRecords" (ByVal hEventLog As Long, NumberOfRecords As Long) As Long

Private Declare Function ReadEventLogStringNT Lib "advapi32.dll" Alias "ReadEventLogA" (ByVal hEventLog As Long, ByVal dwReadFlags As Long, ByVal dwRecordOffset As Long, ByVal lpBuffer As String, ByVal nNumberOfBytesToRead As Long, pnBytesRead As Long, pnMinNumberOfBytesNeeded As Long) As Long

Private Declare Function CloseEventLogNT Lib "advapi32.dll" Alias "CloseEventLog" (ByVal hEventLog As Long) As Long

0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question