Click here to Skip to main content
15,891,597 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi experts,

I'm using System.Diagnostics.EventLog to log some events in an application and its setup.

For an application, I think hard-coded event protocol and source names are OK.

Since windows xp's integrated event viewer shows new events only after the user told him, I wrote an event viewer as well, which makes events show up on creation.

Now I'd like to have this viewer a little generalized. Therefore hard-coded event protocol and source names ar no longer an option. Users could type in protocol and source names, introducing the risk of typing non-existent protocol and source names. Therefore I would like the user to choose protocol and source each from a dropdown containing valid names only.

There is a possibility to get all available protocols through EventLog.GetEventLogs() but I couldn't find one for sources.


Is there a method to get all active sources (for a protocol or in general)?
Posted
Updated 5-Jun-11 22:43pm
v2
Comments
Sergey Alexandrovich Kryukov 1-Jun-11 13:09pm    
Why do you think this is a problem?
--SA
lukeer 6-Jun-11 4:44am    
Updated my question: Need active sources to populate dropdown of valid source names.

1 solution

Here logs(0) is Appliacation logs. You can check your entries first.
VB
Dim logs() As EventLog = EventLog.GetEventLogs()
Dim logsE As EventLogEntryCollection = logs(0).Entries()
ComboBox1.DataSource = (From log As EventLogEntry In logsE Order By log.Source Select log.Source).Distinct.ToArray
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900