473,405 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

is this possible...

hey all,

can you code against the event log, for instance if an entry for a specific
user shows up can i popup a message box notifying me that?

thanks,
mj
Apr 27 '06 #1
2 973
RSS
Yes it is possible. Look at using System.Diagnostics;

It has EventLog object.
"mattie" <ma****@discussions.microsoft.com> wrote in message news:BC**********************************@microsof t.com...
hey all,

can you code against the event log, for instance if an entry for a specific
user shows up can i popup a message box notifying me that?

thanks,
mj

Apr 27 '06 #2
Here is a class I was playing with a while back but never actually finished
because the need disappeared. I do recall that it worked well enough that I
could sucessfully add messages to the event logs and create custom logs. It
should get you on your way...

Imports System.Diagnostics
Imports System.IO
Imports Microsoft.Win32

Public Class EventLogger
'--------------------------------------------------------------------------------------------
'Event Logger
'Written By: Jeff Waskiewicz
'Date: 8/12/2003
'
'Wraps the System.Diagnostics.EventLog Class for Reading and Writing to
the Windows Event Log.
'
'Revision Notes:
'
'

'-------------------------------------------------------------------------------------------------------

Private strSourceName As String
Private strLogName As String
Private strMessageText As String
Private intMessageID As Integer
Private shtCategory As Short
Private MessageEventType As EventLogEntryType
Private EventLog As New System.Diagnostics.EventLog()

'Property to hold the Source shown in Event Viewer
Property EventSource() As String
Get
Return strSourceName
End Get
Set(ByVal Value As String)
strSourceName = Value
End Set
End Property

'Property to hold the Name of the Event Log to be written to
Property LogFileName() As String
Get
Return strLogName
End Get
Set(ByVal Value As String)
strLogName = Value
End Set
End Property

'Property to hold the type of message stored as an EventLogEntryType.
There are 5 types
'Warning, Information, Error, AuditFailed, and AuditSuccess
Property MessageType() As EventLogEntryType
Get
Return MessageEventType
End Get
Set(ByVal Value As EventLogEntryType)
MessageEventType = Value
End Set
End Property

'Property to hold the Message Text
Property MessageText() As String
Get
Return strMessageText
End Get
Set(ByVal Value As String)
strMessageText = Value
End Set
End Property

'Property to hold the application defined Event ID of the Message
Property MessageID() As String
Get
Return intMessageID
End Get
Set(ByVal Value As String)

End Set
End Property

'Property to hold the application defined Category of the Message
Property MessageCategory()
Get
Return shtCategory
End Get
Set(ByVal Value)
shtCategory = Value
End Set
End Property

'Used to Creates a New Event Source and Log File if necessary
Sub CreateSource()
If Not EventLog.SourceExists(strSourceName) Then
EventLog.CreateEventSource(strSourceName, strLogName)
Else
EventLog.DeleteEventSource(strSourceName)
EventLog.CreateEventSource(strSourceName, strLogName)
End If
End Sub

'Used to remove an Event Source
Sub RemoveSource()
If EventLog.SourceExists(strSourceName) Then
EventLog.DeleteEventSource(strSourceName)
End If
End Sub

'Used to Delete a Custom Log File
Sub DeleteLog()
If EventLog.SourceExists(strSourceName) Then
EventLog.Delete(strLogName)
End If
End Sub

'Used to Verify a Source Exists
Function SourceExists() As Boolean
SourceExists = EventLog.SourceExists(strSourceName)
End Function

'Used to Verify a Source Exists
Function LogFileExists() As Boolean
LogFileExists = EventLog.Exists(strLogName)
End Function

'Used to Write a Message to the Event Log
Sub WriteMessage()
EventLog.Source = strSourceName
If shtCategory <> 0 Then
EventLog.WriteEntry(strMessageText, MessageEventType,
intMessageID, shtCategory)
Else
EventLog.WriteEntry(strMessageText, MessageEventType,
intMessageID)
End If
End Sub

'Used to Read Messages from Event Log
Private Function ReadMessages()
MsgBox("Not Implemented")
End Function

Private Sub ClearLog()
MsgBox("Not Implemented")
End Sub

End Class
Apr 28 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Bhupesh Naik | last post by:
This is a query regarding my problem to make a spell and grammar check possible in text area of a web page. We have aspx pages which are used to construct letters. The browser based screens...
1
by: AAA | last post by:
hi, I'll explain fastly the program that i'm doing.. the computer asks me to enter the cardinal of a set X ( called "dimX" type integer)where X is a table of one dimension and then to fill it...
25
by: Piotr Nowak | last post by:
Hi, Say i have a server process which listens for some changes in database. When a change occurs i want to refresh my page in browser by notyfinig it. I do not want to refresh my page i.e....
4
by: RSH | last post by:
Okay my math skills aren't waht they used to be... With that being said what Im trying to do is create a matrix that given x number of columns, and y number of possible values i want to generate...
7
by: Robert S. | last post by:
Searching some time now for documents on this but still did not find anything about it: Is it possible to replace the entry screen of MS Office Access 2007 - that one presenting that default...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.