165
163
schSCManager = OpenSCManager(
166
@@ -366,19 +384,19 @@
169
schService = CreateService(
170
- schSCManager, // SCManager database
171
- TEXT(SZSERVICENAME), // name of service
172
- TEXT(SZSERVICEDISPLAYNAME), // name to display
173
- SERVICE_QUERY_STATUS, // desired access
174
- SERVICE_WIN32_OWN_PROCESS, // service type
165
TEXT(SZSERVICEDISPLAYNAME), // name to display
166
SERVICE_QUERY_STATUS, // desired access
167
SERVICE_WIN32_OWN_PROCESS, // service type
175
168
- SERVICE_DEMAND_START, // start type
176
- SERVICE_ERROR_NORMAL, // error control type
177
- szPath, // service's binary
178
- NULL, // no load ordering group
179
- NULL, // no tag identifier
180
- TEXT(SZDEPENDENCIES), // dependencies
181
- NULL, // LocalSystem account
182
- NULL); // no password
183
+ schSCManager, // SCManager database
184
+ TEXT(SZSERVICENAME), // name of service
185
+ TEXT(SZSERVICEDISPLAYNAME), // name to display
186
+ SERVICE_QUERY_STATUS, // desired access
187
+ SERVICE_WIN32_OWN_PROCESS, // service type
188
169
+ SERVICE_DEMAND_START, // start type -- alternative: SERVICE_AUTO_START
189
+ SERVICE_ERROR_NORMAL, // error control type
190
+ szPath, // service's binary
191
+ NULL, // no load ordering group
192
+ NULL, // no tag identifier
193
+ TEXT(SZDEPENDENCIES), // dependencies
194
+ NULL, // LocalSystem account
195
+ NULL); // no password
199
@@ -388,15 +406,78 @@
170
SERVICE_ERROR_NORMAL, // error control type
171
szPath, // service's binary
172
NULL, // no load ordering group
173
@@ -388,16 +406,79 @@
202
176
_tprintf(TEXT("CreateService failed - %s\n"), GetLastErrorText(szErr, 256));
206
180
CloseServiceHandle(schSCManager);
209
- _tprintf(TEXT("OpenSCManager failed - %s\n"), GetLastErrorText(szErr,256));
211
+ _tprintf(TEXT("OpenSCManager failed - %s\n"), GetLastErrorText(szErr,256));
184
_tprintf(TEXT("OpenSCManager failed - %s\n"), GetLastErrorText(szErr,256));
249
222
+ schService = OpenService(
250
223
+ schSCManager, // SCM database
251
+ "MeetrixService", // service name
224
+ SZSERVICENAME, // service name
252
225
+ SERVICE_ALL_ACCESS);
254
227
+ if (schService == NULL) {
300
274
if ( ssStatus.dwCurrentState == SERVICE_STOPPED )
301
275
_tprintf(TEXT("\n%s stopped.\n"), TEXT(SZSERVICEDISPLAYNAME) );
303
- _tprintf(TEXT("\n%s failed to stop.\n"), TEXT(SZSERVICEDISPLAYNAME) );
305
+ _tprintf(TEXT("\n%s failed to stop.\n"), TEXT(SZSERVICEDISPLAYNAME) );
278
_tprintf(TEXT("\n%s failed to stop.\n"), TEXT(SZSERVICEDISPLAYNAME) );
312
285
if ( DeleteService(schService) )
313
286
_tprintf(TEXT("%s removed.\n"), TEXT(SZSERVICEDISPLAYNAME) );
315
- _tprintf(TEXT("DeleteService failed - %s\n"), GetLastErrorText(szErr,256));
317
+ _tprintf(TEXT("DeleteService failed - %s\n"), GetLastErrorText(szErr,256));
289
_tprintf(TEXT("DeleteService failed - %s\n"), GetLastErrorText(szErr,256));
322
294
CloseServiceHandle(schService);
325
- _tprintf(TEXT("OpenService failed - %s\n"), GetLastErrorText(szErr,256));
327
+ _tprintf(TEXT("OpenService failed - %s\n"), GetLastErrorText(szErr,256));
298
_tprintf(TEXT("OpenService failed - %s\n"), GetLastErrorText(szErr,256));
331
302
CloseServiceHandle(schSCManager);
334
- _tprintf(TEXT("OpenSCManager failed - %s\n"), GetLastErrorText(szErr,256));
336
+ _tprintf(TEXT("OpenSCManager failed - %s\n"), GetLastErrorText(szErr,256));
306
_tprintf(TEXT("OpenSCManager failed - %s\n"), GetLastErrorText(szErr,256));