?
Solved

Reading from the NT Event Log

Posted on 1998-10-05
5
Medium Priority
?
176 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 100 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month11 days, 20 hours left to enroll

752 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