| | |
2008 displaying the task category vista event logs
Please support our VB.NET advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Mar 2008
Posts: 44
Reputation:
Solved Threads: 0
Hi all,
I am currently displaying the information stored in the security logs in event viewer in vista.
But i cannot get the category task to display like it is in vista (Special logon, logon, audit policy change)
when i use evententry.category.tostring it just displays a number.
Anyone know how to fix this
I am currently displaying the information stored in the security logs in event viewer in vista.
But i cannot get the category task to display like it is in vista (Special logon, logon, audit policy change)
when i use evententry.category.tostring it just displays a number.
Anyone know how to fix this
•
•
•
•
when i use evententry.category.tostring it just displays a number.
This is the "basic" code to dump event log
VB.NET Syntax (Toggle Plain Text)
Dim oEvLog As EventLog Dim oEvEntry As EventLogEntry oEvLog = New EventLog("Security") For Each oEvEntry In oEvLog.Entries Debug.Print(oEvEntry.Category) Next
Teme64 @ Windows Developer Blog
Here's what MSDN says about EventLogEntry.CategoryNumber
I checked the code in Vista. For some reason Security event categories were all dumped as CategoryNumber. I checked Application event categories and I got category numbers but also textual category names when one existed.
So, if you want to get names for the categories, instead of the category numbers, you'll have to find which is the resource file and use category number to get textual name directly from the resource file.
I'm just guessing how this should be done. There may be a much better way to do it, I just didn't figure it out.
•
•
•
•
The Event Viewer can display the category as a numeric value, or it can use the category as a resource identifier to display a localized category string.
So, if you want to get names for the categories, instead of the category numbers, you'll have to find which is the resource file and use category number to get textual name directly from the resource file.
I'm just guessing how this should be done. There may be a much better way to do it, I just didn't figure it out.
Teme64 @ Windows Developer Blog
•
•
Join Date: Jul 2007
Posts: 276
Reputation:
Solved Threads: 37
Have you tried just
EventLogEntry.Category ? (I saw you said evententry.category)
http://msdn.microsoft.com/en-us/libr...ry(VS.80).aspx
msdn says that this gets the text associated with the number, that doesn't work?
EventLogEntry.Category ? (I saw you said evententry.category)
http://msdn.microsoft.com/en-us/libr...ry(VS.80).aspx
msdn says that this gets the text associated with the number, that doesn't work?
Yes. That's what the code above (post #2) used. The problem is that EventLogEntry.Category returns EventLogEntry.CategoryNumber if there's no text (= localized string) associated with CategoryNumber. Not exactly a problem, it's supposed to work that way.
The problem came while dumping "Security" event log in Vista. EventLogEntry.Category always returned EventLogEntry.CategoryNumber for some reason.
The problem came while dumping "Security" event log in Vista. EventLogEntry.Category always returned EventLogEntry.CategoryNumber for some reason.
Teme64 @ Windows Developer Blog
•
•
Join Date: Jul 2007
Posts: 276
Reputation:
Solved Threads: 37
Sorry Teme I totally read past that, I see it now.
The problem was found by someone writing C# as well and there is a solution, so it has to translate to vb.net as well. I'm just not experienced enough to do this well.
http://www.codeguru.com/forum/archiv.../t-264190.html
the full C# code was here http://www.codeproject.com/KB/system/sysevent.aspx
it's the format message that needs to happen right?
The problem was found by someone writing C# as well and there is a solution, so it has to translate to vb.net as well. I'm just not experienced enough to do this well.
http://www.codeguru.com/forum/archiv.../t-264190.html
the full C# code was here http://www.codeproject.com/KB/system/sysevent.aspx
it's the format message that needs to happen right?
Code was for WinNT event log. I downloaded that project and it didn't work in XP. And the most important thing, category name, was missing. Maybe WinNT didn't have category names(?).
Also the OP (in that CodeGuru thread) ended to the same conclusion:
Also the OP (in that CodeGuru thread) ended to the same conclusion:
•
•
•
•
RookieRitwik September 23rd, 2003, 02:26 AM
I got the user name working. It uses lookupsid account. However I cant get the event category. I only get numbers.
Teme64 @ Windows Developer Blog
•
•
Join Date: Jul 2007
Posts: 276
Reputation:
Solved Threads: 37
You're right, I stand corrected. It looked like they did this to add it to XP though
will that work with what he wants to do? They are manually setting the header right?
VB.NET Syntax (Toggle Plain Text)
' Setup the dataset ' (Don't forget to set the DataType of the "Date/Time" column) ds = New DataSet("EventLog Entries") ds.Tables.Add("Events") With ds.Tables("Events") .Columns.Add("Type") .Columns.Add("Date/Time") .Columns("Date/Time").DataType = GetType(System.DateTime) .Columns.Add("Message") .Columns.Add("Source") .Columns.Add("Category") .Columns.Add("EventID") End With ... ' Set the column type of the DataGridView as well! If col.Name = "Date/Time" Then col.ValueType = GetType(System.DateTime) End If
will that work with what he wants to do? They are manually setting the header right?
![]() |
Other Threads in the VB.NET Forum
- Previous Thread: Crystal report in vb.net, printing problems
- Next Thread: How to use DOS command in vb.net
Views: 1072 | Replies: 8
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
"crystal .net .net2005 2008 access add application array assignment basic box button buttons center class click code combo convert cpu data database datagrid datagridview design designer dissertation dissertations dissertationthesis dosconsolevb.net editvb.net employees error excel exists firewall function image images isnumericfuntioncall listview login map math memory mobile module msaccess mssqlbackend mysql navigate net opacity page pan picturebox port print printing printpreview problem record refresh regex reports" reuse right-to-left save savedialog search serial socket sorting sql sqldatbase storedprocedure string structures studio temp textbox timer txttoxmlconverter upload useraccounts usercontol usercontrol vb vb.net vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet vista visual visualbasic visualbasic.net visualstudio2008 web wpf xml





