As a simple example, the following code can be used to test a service. Once the steps are followed to create a service, procedures for handling the start and stop event of the service is automatically created. These events can be tested by putting a log entry. The code might look like this:
For C# project:
protected override void OnStart(string[] args)
{
EventLog.WriteEntry( String.Format("Process Starting…") );
}
For Visual Basic project:
Protected Overrides Sub OnStart(ByVal args() As String)
EventLog.WriteEntry( String.Format("Process Starting…"))
End Sub
The logged entry can be viewed from the Event Viewer applet.