markus / ConvertService / ConverterService / FinalService_Watcher / ProjectInstaller.cs @ 87542f92
이력 | 보기 | 이력해설 | 다운로드 (1.26 KB)
1 |
using System; |
---|---|
2 |
using System.Collections; |
3 |
using System.Collections.Generic; |
4 |
using System.ComponentModel; |
5 |
using System.Configuration.Install; |
6 |
using System.Linq; |
7 |
using System.ServiceProcess; |
8 |
|
9 |
|
10 |
namespace FinalService_Watcher |
11 |
{ |
12 |
[RunInstaller(true)] |
13 |
public partial class ProjectInstaller : System.Configuration.Install.Installer |
14 |
{ |
15 |
public ProjectInstaller() |
16 |
{ |
17 |
InitializeComponent(); |
18 |
} |
19 |
|
20 |
public override void Install(IDictionary stateSaver) |
21 |
{ |
22 |
base.Install(stateSaver); |
23 |
|
24 |
ServiceController controller = new ServiceController(FinalService_WatcherInstaller.ServiceName); |
25 |
try |
26 |
{ |
27 |
controller.Start(); |
28 |
} |
29 |
catch (Exception ex) |
30 |
{ |
31 |
//_log.Write(ex.ToString()); |
32 |
} |
33 |
} |
34 |
|
35 |
protected override void OnBeforeUninstall(IDictionary savedState) |
36 |
{ |
37 |
base.OnBeforeUninstall(savedState); |
38 |
|
39 |
ServiceController controller = new ServiceController(FinalService_WatcherInstaller.ServiceName); |
40 |
|
41 |
try |
42 |
{ |
43 |
controller.Stop(); |
44 |
} |
45 |
catch (Exception ex) |
46 |
{ |
47 |
//_log.Write(ex.ToString()); |
48 |
} |
49 |
} |
50 |
} |
51 |
} |