[NET][MC] Move generic strings from net.exe to netmsg.dll.
[reactos.git] / 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 ConResPuts(StdOut, IDS_GENERIC_SYNTAX);
23 PrintNetMessage(MSG_PAUSE_SYNTAX);
24 return 1;
25 }
26
27 for (i = 2; i < argc; i++)
28 {
29 if (_wcsicmp(argv[i], L"/help") == 0)
30 {
31 ConResPuts(StdOut, IDS_GENERIC_SYNTAX);
32 PrintNetMessage(MSG_PAUSE_SYNTAX);
33 PrintNetMessage(MSG_PAUSE_HELP);
34 return 1;
35 }
36 }
37
38 hManager = OpenSCManager(NULL, SERVICES_ACTIVE_DATABASE, SC_MANAGER_ENUMERATE_SERVICE);
39 if (hManager == NULL)
40 {
41 ConPrintf(StdErr, L"[OpenSCManager] Error: %ld\n", GetLastError());
42 nError = 1;
43 goto done;
44 }
45
46 hService = OpenService(hManager, argv[2], SERVICE_PAUSE_CONTINUE);
47 if (hService == NULL)
48 {
49 ConPrintf(StdErr, L"[OpenService] Error: %ld\n", GetLastError());
50 nError = 1;
51 goto done;
52 }
53
54 if (!ControlService(hService, SERVICE_CONTROL_PAUSE, &status))
55 {
56 ConPrintf(StdErr, L"[ControlService] Error: %ld\n", GetLastError());
57 }
58
59 done:
60 if (hService != NULL)
61 CloseServiceHandle(hService);
62
63 if (hManager != NULL)
64 CloseServiceHandle(hManager);
65
66 return nError;
67 }
68
69 /* EOF */
70