/[cvs]/joko/TestArea/vb/NtServices/ServiceApp/FirstSteps/sample.Frm
ViewVC logotype

Contents of /joko/TestArea/vb/NtServices/ServiceApp/FirstSteps/sample.Frm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Mon Jan 20 19:21:32 2003 UTC (21 years, 10 months ago) by joko
Branch: MAIN
CVS Tags: HEAD
Error occurred while calculating annotation data.
+ initial check-in

1 VERSION 5.00
2 Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
3 Object = "{E7BC34A0-BA86-11CF-84B1-CBC2DA68BF6C}#1.0#0"; "NTSVC.ocx"
4 Begin VB.Form ServiceMain
5 Caption = "Sample NT Service"
6 ClientHeight = 2085
7 ClientLeft = 1395
8 ClientTop = 1620
9 ClientWidth = 6180
10 Icon = "sample.frx":0000
11 LinkTopic = "Form1"
12 PaletteMode = 1 'UseZOrder
13 ScaleHeight = 2085
14 ScaleWidth = 6180
15 Begin VB.CommandButton Command2
16 Caption = "Uninstall"
17 Height = 375
18 Left = 3600
19 TabIndex = 2
20 Top = 720
21 Width = 1695
22 End
23 Begin VB.CommandButton Command5
24 Caption = "Stop"
25 Height = 375
26 Left = 1920
27 TabIndex = 4
28 Top = 720
29 Width = 1695
30 End
31 Begin VB.CommandButton Command1
32 Caption = "Install"
33 Height = 375
34 Left = 3600
35 TabIndex = 1
36 Top = 360
37 Width = 1695
38 End
39 Begin VB.Timer Timer
40 Left = 960
41 Top = 360
42 End
43 Begin NTService.NTService NTService1
44 Left = 240
45 Top = 360
46 _Version = 65536
47 _ExtentX = 741
48 _ExtentY = 741
49 _StockProps = 0
50 DisplayName = "a7"
51 ServiceName = "a7"
52 StartMode = 3
53 End
54 Begin ComctlLib.StatusBar StatusBar
55 Align = 2 'Align Bottom
56 Height = 300
57 Left = 0
58 TabIndex = 0
59 Top = 1785
60 Width = 6180
61 _ExtentX = 10901
62 _ExtentY = 529
63 SimpleText = ""
64 _Version = 327682
65 BeginProperty Panels {0713E89E-850A-101B-AFC0-4210102A8DA7}
66 NumPanels = 2
67 BeginProperty Panel1 {0713E89F-850A-101B-AFC0-4210102A8DA7}
68 TextSave = ""
69 Key = ""
70 Object.Tag = ""
71 EndProperty
72 BeginProperty Panel2 {0713E89F-850A-101B-AFC0-4210102A8DA7}
73 TextSave = ""
74 Key = ""
75 Object.Tag = ""
76 EndProperty
77 EndProperty
78 End
79 Begin VB.CommandButton Command4
80 Caption = "Start"
81 Height = 375
82 Left = 1920
83 TabIndex = 3
84 Top = 360
85 Width = 1695
86 End
87 End
88 Attribute VB_Name = "ServiceMain"
89 Attribute VB_GlobalNameSpace = False
90 Attribute VB_Creatable = False
91 Attribute VB_PredeclaredId = True
92 Attribute VB_Exposed = False
93 Option Explicit
94
95 Dim serviceControl As New clsServiceControl
96 Dim bool_isService As Boolean
97
98 Private Sub Command4_Click()
99 serviceControl.doStart False
100 End Sub
101
102 Private Sub Form_Load()
103 MsgBox App.StartMode & ";" & App.TaskVisible
104
105 If Command = "-gui" Then
106 bool_isService = False
107 Else
108 bool_isService = True
109 End If
110
111 With serviceControl
112 .setRefs NTService1, Timer
113 .setInterval 250
114 If bool_isService Then
115 setCurrentStatus "Loading"
116 .doStart True
117 End If
118 End With
119 End Sub
120
121 Private Sub Form_Unload(Cancel As Integer)
122 'serviceControl.doStop
123 End Sub
124
125 Private Sub Command1_Click()
126 serviceControl.doInstall
127 End Sub
128
129 Private Sub Command2_Click()
130 serviceControl.doUninstall
131 End Sub
132
133 Private Sub NTService1_Control(ByVal e As Long)
134 On Error GoTo Err_Control
135
136 'StatusBar.SimpleText = NTService1.DisplayName & " Control signal " & e
137 Exit Sub
138
139 Err_Control:
140 Call NTService1.LogEvent(svcMessageError, svcEventError, "[" & Err.Number & "] " & Err.Description)
141 End Sub
142
143 Private Sub NTService1_Start(Success As Boolean)
144 On Error GoTo Err_Start
145
146 StatusBar.Panels(1).Text = "Running"
147 Success = True
148 Call NTService1.LogEvent(SvcEventType.svcEventSuccess, 0, "Service started successfully")
149 'Unload Me
150 'Exit Sub
151
152 Err_Start:
153 Call NTService1.LogEvent(svcMessageError, svcEventError, "[" & Err.Number & "] " & Err.Description)
154 End Sub
155
156 Private Sub NTService1_Stop()
157 On Error GoTo Err_Stop
158
159 Call NTService1.LogEvent(SvcEventType.svcEventInformation, 0, "Service recieved stop-request")
160
161 StatusBar.Panels(1).Text = "Stopped"
162 If Not NTService1.Debug Then
163 Unload Me
164 End
165 End If
166 Exit Sub
167
168 Err_Stop:
169 Call NTService1.LogEvent(svcMessageError, svcEventError, "[" & Err.Number & "] " & Err.Description)
170 End Sub
171
172 Private Sub NTService1_Pause(Success As Boolean)
173 On Error GoTo Err_Pause
174
175 Timer.Enabled = False
176 StatusBar.Panels(1).Text = "Paused"
177 Call NTService1.LogEvent(SvcEventType.svcEventInformation, svcMessageInfo, "Service paused")
178 Success = True
179 Exit Sub
180
181 Err_Pause:
182 Call NTService1.LogEvent(svcMessageError, svcEventError, "[" & Err.Number & "] " & Err.Description)
183 End Sub
184
185 Private Sub NTService1_Continue(Success As Boolean)
186 On Error GoTo Err_Continue
187
188 Timer.Enabled = True
189 StatusBar.Panels(1).Text = "Running"
190 Success = True
191 Call NTService1.LogEvent(SvcEventType.svcEventInformation, svcMessageInfo, "Service continued")
192 Exit Sub
193
194 Err_Continue:
195 Call NTService1.LogEvent(svcMessageError, svcEventError, "[" & Err.Number & "] " & Err.Description)
196 End Sub
197
198 Private Sub Timer_Timer()
199
200 Dim curData As String
201
202 On Error GoTo Err_Timer
203 curData = Format(Now(), "hh:mm:ss")
204 StatusBar.Panels(2).Text = curData
205 Call NTService1.LogEvent(SvcEventType.svcEventInformation, 0, "running: " & curData)
206 Exit Sub
207
208 Err_Timer:
209 Call NTService1.LogEvent(svcMessageError, svcEventError, "[" & Err.Number & "] " & Err.Description)
210 End Sub
211

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed