mirror of
https://github.com/fergalmoran/DnsServer.git
synced 2025-12-22 09:29:50 +00:00
39 lines
996 B
C#
39 lines
996 B
C#
using System.ComponentModel;
|
|
using System.Configuration.Install;
|
|
using System.ServiceProcess;
|
|
|
|
namespace DnsService
|
|
{
|
|
[RunInstaller(true)]
|
|
public partial class ProjectInstaller : Installer
|
|
{
|
|
public ProjectInstaller()
|
|
{
|
|
InitializeComponent();
|
|
|
|
serviceInstaller1.AfterInstall += ServiceInstaller1_AfterInstall;
|
|
serviceInstaller1.BeforeUninstall += ServiceInstaller1_BeforeUninstall;
|
|
}
|
|
|
|
private void ServiceInstaller1_AfterInstall(object sender, InstallEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
new ServiceController(serviceInstaller1.ServiceName).Start();
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
|
|
private void ServiceInstaller1_BeforeUninstall(object sender, InstallEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
new ServiceController(serviceInstaller1.ServiceName).Stop();
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
}
|
|
}
|