[NET]
[reactos.git] / reactos / base / applications / network / net / cmdPause.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS net command
4 * FILE: cmdPause.c
5 * PURPOSE:
6 *
7 * PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
8 */
9
10 #include "net.h"
11
12 INT cmdPause(INT argc, WCHAR **argv)
13 {
14 SC_HANDLE hManager = NULL;
15 SC_HANDLE hService = NULL;
16 SERVICE_STATUS status;
17 INT nError = 0;
18
19 if (argc != 3)
20 {
21 PrintResourceString(IDS_PAUSE_SYNTAX);
22 return 1;
23 }
24
25 hManager = OpenSCManager(NULL, SERVICES_ACTIVE_DATABASE, SC_MANAGER_ENUMERATE_SERVICE);
26 if (hManager == NULL)
27 {
28 printf("[OpenSCManager] Error: %ld\n", GetLastError());
29 nError = 1;
30 goto done;
31 }
32
33 hService = OpenService(hManager, argv[2], SERVICE_PAUSE_CONTINUE);
34 if (hService == NULL)
35 {
36 printf("[OpenService] Error: %ld\n", GetLastError());
37 nError = 1;
38 goto done;
39 }
40
41 if (!ControlService(hService, SERVICE_CONTROL_PAUSE, &status))
42 {
43 printf("[ControlService] Error: %ld\n", GetLastError());
44 }
45
46 done:
47 if (hService != NULL)
48 CloseServiceHandle(hService);
49
50 if (hManager != NULL)
51 CloseServiceHandle(hManager);
52
53 return nError;
54 }
55
56 /* EOF */
57