[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: base/applications/network/net/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 INT i;
19
20 if (argc != 3)
21 {
22 PrintResourceString(IDS_PAUSE_SYNTAX);
23 return 1;
24 }
25
26 for (i = 2; i < argc; i++)
27 {
28 if (_wcsicmp(argv[i], L"/help") == 0)
29 {
30 PrintResourceString(IDS_PAUSE_HELP);
31 return 1;
32 }
33 }
34
35 hManager = OpenSCManager(NULL, SERVICES_ACTIVE_DATABASE, SC_MANAGER_ENUMERATE_SERVICE);
36 if (hManager == NULL)
37 {
38 printf("[OpenSCManager] Error: %ld\n", GetLastError());
39 nError = 1;
40 goto done;
41 }
42
43 hService = OpenService(hManager, argv[2], SERVICE_PAUSE_CONTINUE);
44 if (hService == NULL)
45 {
46 printf("[OpenService] Error: %ld\n", GetLastError());
47 nError = 1;
48 goto done;
49 }
50
51 if (!ControlService(hService, SERVICE_CONTROL_PAUSE, &status))
52 {
53 printf("[ControlService] Error: %ld\n", GetLastError());
54 }
55
56 done:
57 if (hService != NULL)
58 CloseServiceHandle(hService);
59
60 if (hManager != NULL)
61 CloseServiceHandle(hManager);
62
63 return nError;
64 }
65
66 /* EOF */
67