summaryrefslogtreecommitdiff
path: root/windows/ZeroTierOneService/Service.cs
blob: f706802af5de70cdfbe00d48980e64c281b62d12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System;
using System.IO;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;

namespace ZeroTierOneService
{
    public partial class Service : ServiceBase
    {
        public Service()
        {
            InitializeComponent();

            this.ztHome = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + Path.DirectorySeparatorChar + "ZeroTier" + Path.DirectorySeparatorChar + "One";
            this.ztUpdatesFolder = this.ztHome + Path.DirectorySeparatorChar + "updates.d";
            this.ztBinary = this.ztHome + Path.DirectorySeparatorChar + (Environment.Is64BitOperatingSystem ? "zerotier-one_x64.exe" : "zerotier-one_x86.exe");

            this.ztService = null;
        }

        protected override void OnStart(string[] args)
        {
            startZeroTierService();
        }

        protected override void OnStop()
        {
            stopZeroTierService();
        }

        private void startZeroTierService()
        {
        }

        private void stopZeroTierService()
        {
            if (ztService != null)
            {
                ztService.Kill();
                ztService = null;
            }
        }

        private void ztService_Exited(object sender, System.EventArgs e)
        {
        }

        private string ztHome;
        private string ztUpdatesFolder;
        private string ztBinary;

        private Process ztService;
    }
}