Advertisement
andrzejiwaniuk

[Napisz sam] Jak stworzyć wlasną uslugę Windows 8

Jun 13th, 2013
558
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Diagnostics;
  6. using System.Linq;
  7. using System.ServiceProcess;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10.  
  11. namespace HackedAndrzejService
  12. {
  13.     public partial class Service1 : ServiceBase
  14.     {
  15.         public Service1()
  16.         {
  17.             InitializeComponent();
  18.             if (!System.Diagnostics.EventLog.SourceExists("testowaUslugaAndrzej"))
  19.             {
  20.                 System.Diagnostics.EventLog.CreateEventSource(
  21.                     "testowaUslugaAndrzej", "Andrzej Hacked Usluga");
  22.             }
  23.             eventLog1.Source = "testowaUslugaAndrzej";
  24.             eventLog1.Log = "Andrzej Hacked Usluga";
  25.         }
  26.  
  27.         protected override void OnStart(string[] args)
  28.         {
  29.             eventLog1.WriteEntry("Usluga uruchomiona :)");
  30.         }
  31.  
  32.         protected override void OnStop()
  33.         {
  34.             eventLog1.WriteEntry("Usluga zatrzymana :( ");
  35.         }
  36.         protected override void OnContinue()
  37.         {
  38.             eventLog1.WriteEntry("Usluga uruchomiona");
  39.         }  
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement