diff --git a/WpkgInstaller/WpkgInstaller.Designer.cs b/WpkgInstaller/WpkgInstaller.Designer.cs index 488aabd31fc70a1ec03204c451e979cf3f8dfc01..4a43dca1d5c45f6295f244bdc23062c05f4503d4 100755 --- a/WpkgInstaller/WpkgInstaller.Designer.cs +++ b/WpkgInstaller/WpkgInstaller.Designer.cs @@ -33,7 +33,6 @@ // // eventLog // - this.eventLog.MachineName = ".eventLog"; this.eventLog.EntryWritten += new System.Diagnostics.EntryWrittenEventHandler(this.eventLog_EntryWritten); // // WpkgInstaller diff --git a/WpkgInstaller/WpkgInstaller.cs b/WpkgInstaller/WpkgInstaller.cs index 318917558dcd61ea498bc130daec71c3707aa653..cf38bd4be10d1b33ad14b3b7f6ae744e63765f38 100755 --- a/WpkgInstaller/WpkgInstaller.cs +++ b/WpkgInstaller/WpkgInstaller.cs @@ -1,5 +1,7 @@ using System.Runtime.InteropServices; using System.ServiceProcess; +using System.Diagnostics; +using System; namespace WpkgInstaller { @@ -33,17 +35,24 @@ namespace WpkgInstaller public WpkgInstaller() { InitializeComponent(); - if (!System.Diagnostics.EventLog.SourceExists("WpkgInstaller")) + + eventLog = new EventLog(); + string eventSourceName = "WpkgInstaller Service"; + string logName = "WpkgNotifier"; + + if (!EventLog.SourceExists(eventSourceName)) { - System.Diagnostics.EventLog.CreateEventSource( - "WpkgInstaller", "WpkgNotifier"); + EventLog.CreateEventSource(eventSourceName, logName); } - eventLog.Source = "WpkgNotifier"; - eventLog.Log = "WpkgInstaller"; + + eventLog.Source = eventSourceName; + eventLog.Log = logName; + } protected override void OnStart(string[] args) { + ServiceStatus serviceStatus = new ServiceStatus(); serviceStatus.dwCurrentState = ServiceState.SERVICE_START_PENDING; serviceStatus.dwWaitHint = 100000; @@ -52,7 +61,7 @@ namespace WpkgInstaller serviceStatus.dwCurrentState = ServiceState.SERVICE_RUNNING; SetServiceStatus(this.ServiceHandle, ref serviceStatus); - eventLog.WriteEntry("Service started"); + eventLog.WriteEntry("Service started", EventLogEntryType.Information); } protected override void OnStop() @@ -65,12 +74,13 @@ namespace WpkgInstaller serviceStatus.dwCurrentState = ServiceState.SERVICE_STOPPED; SetServiceStatus(this.ServiceHandle, ref serviceStatus); - eventLog.WriteEntry("Service stopped"); + eventLog.WriteEntry("Service stopped", EventLogEntryType.Information); } private void eventLog_EntryWritten(object sender, System.Diagnostics.EntryWrittenEventArgs e) { } + } }