Solved

Reading from the NT Event Log

Posted on 1998-10-05
5
168 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
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

759 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now