Solved

Reading from the NT Event Log

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

867 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

18 Experts available now in Live!

Get 1:1 Help Now