Solved

Reading from the NT Event Log

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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

777 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