473,385 Members | 1,474 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,385 software developers and data experts.

Making an entry in Windows XP/2000's event log

Hi,

Does anyone know of the top of their head, how I would add an entry to the
event logs in XP/2000 machines?

Thanks all

Simon
Nov 15 '05 #1
3 1585
System.Diagnostics.EventLog.WriteEntry("MyApp", "Hi there")

The are more examples in the help, search for "EventLog class".

--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada
"Simon Harvey" <si**********@the-web-works.co.uk> wrote in message
news:Ob*************@TK2MSFTNGP12.phx.gbl...
Hi,

Does anyone know of the top of their head, how I would add an entry to the
event logs in XP/2000 machines?

Thanks all

Simon

Nov 15 '05 #2
Hi Simon,

You can use the managed class EventLog in the System.Diagnostics namespace
and it's WriteEntry method. Please see
ms-help://MS.VSCC.2003/MS.MSDNQTR.2004JAN.1033/cpref/html/frlrfsystemdiagnosticseventlogmemberstopic.htm
or
http://msdn.microsoft.com/library/de...classtopic.asp

--
Sam Gentile
MVP - .NET/C#
http://samgentile.com/blog/
Disclaimer: Please do not contact me directly, use the newsgroup
"Simon Harvey" <si**********@the-web-works.co.uk> wrote in message
news:Ob*************@TK2MSFTNGP12.phx.gbl...
Hi,

Does anyone know of the top of their head, how I would add an entry to the
event logs in XP/2000 machines?

Thanks all

Simon

Nov 15 '05 #3
You can even register your own event source and create your custom event log.

The eventlogs are differentiated by the first 8 characters of their name, so be careful about that.

The code that creates your custom event log and registers event source must be run with appropriate access rights to EventLog keys in registry. You need to have full access rights to the following key:

HKLM\System\CurrentControlSet\Service\EventLog
(use regedt32.exe to set permissions)

The following code registers your custom event source and creates the log:

System.Diagnostics.EventLog el = new System.Diagnostics.EventLog ();
if (!System.Diagnostics.EventLog.SourceExists (strSource))
System.Diagnostics.EventLog.CreateEventSource (strSource, strLog);
else if (System.Diagnostics.EventLog.LogNameFromSourceName (strSource, ".") != strLog)
{
System.Diagnostics.EventLog.DeleteEventSource (strSource);
System.Diagnostics.EventLog.CreateEventSource (strSource, strLog);
}

Another quite convinient solution is to use the VS.Net designer, create a component class, and use the EventLog component from the component Toolbox. Then you can even easily add automatic intsallers to the project.

--
Cezary Nolewajka
mailto:c.*********************@no-sp-am-eh-mail.com
remove all "no-sp-am-eh"s to reply
"Simon Harvey" <si**********@the-web-works.co.uk> wrote in message news:Ob*************@TK2MSFTNGP12.phx.gbl...
Hi,

Does anyone know of the top of their head, how I would add an entry to the
event logs in XP/2000 machines?

Thanks all

Simon

Nov 15 '05 #4

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

Similar topics

0
by: wang xiaoyu | last post by:
Hello,everyone. my program runs well in windows,i use tkSimpleDialog to receive some input,but when i copy my program into Linux RH8.0,entrys in my tkSimpleDialog derived Dialog have a vital...
5
by: RAJ | last post by:
hi plz tell me how to know "how window is going to close"... i have to right code for X button of forms... plz telll me thanks bye
0
by: Clark Laughlin | last post by:
I am trying to establish an SSL connection to our company's LDAP server from an ASP.NET application running on Windows 2003 Server and I am getting the following set of event log errors: Event...
3
by: Wade | last post by:
Hi all, I've created a windows service that occasionally writes information into an event log. I have the following function created in a class-library for the windows service: Public Shared...
0
by: cherryparadise001 | last post by:
Hi All, I have moved an asp system from Window Server 2000 to Window Server 2003 recently. Many error occured and most of them are unable to get the control's value in the page. I am newbie to...
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...
2
by: ketty_ng81 | last post by:
No matter how many dial up networking entries I have, the RASWrapper.RasEnumEntries(null , null , entryNames, ref cb, out entries); always returns the right number of elelments in entryNames but...
53
by: Aaron Gray | last post by:
I jokingly say this is the late entry :) Okay I have read all the event entry comments from John's Resig's AddEvent comepition blog :- http://ejohn.org/projects/flexible-javascript-events/ ...
7
by: =?Utf-8?B?QU9UWCBTYW4gQW50b25pbw==?= | last post by:
Hi, I have been using the code (some of it has been removed for simplicity) below to allow authenticated (using ASP.NET membership database) users to get a file from their archive area. It...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?

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.