ReactOS  0.4.12-dev-43-g63b00d8
cmdPause.c
Go to the documentation of this file.
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 
13 {
14  SC_HANDLE hManager = NULL;
15  SC_HANDLE hService = NULL;
17  INT nError = 0;
18  INT i;
19 
20  if (argc != 3)
21  {
24  return 1;
25  }
26 
27  for (i = 2; i < argc; i++)
28  {
29  if (_wcsicmp(argv[i], L"/help") == 0)
30  {
35  return 1;
36  }
37  }
38 
40  if (hManager == NULL)
41  {
42  ConPrintf(StdErr, L"[OpenSCManager] Error: %ld\n", GetLastError());
43  nError = 1;
44  goto done;
45  }
46 
47  hService = OpenService(hManager, argv[2], SERVICE_PAUSE_CONTINUE);
48  if (hService == NULL)
49  {
50  ConPrintf(StdErr, L"[OpenService] Error: %ld\n", GetLastError());
51  nError = 1;
52  goto done;
53  }
54 
55  if (!ControlService(hService, SERVICE_CONTROL_PAUSE, &status))
56  {
57  ConPrintf(StdErr, L"[ControlService] Error: %ld\n", GetLastError());
58  }
59 
60 done:
61  if (hService != NULL)
62  CloseServiceHandle(hService);
63 
64  if (hManager != NULL)
65  CloseServiceHandle(hManager);
66 
67  return nError;
68 }
69 
70 /* EOF */
71 
static int argc
Definition: ServiceArgs.c:12
#define SC_MANAGER_ENUMERATE_SERVICE
Definition: winsvc.h:16
#define SERVICES_ACTIVE_DATABASE
Definition: winsvc.h:564
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
int32_t INT
Definition: typedefs.h:56
#define OpenService
Definition: winsvc.h:576
static char ** argv
Definition: ServiceArgs.c:11
#define IDS_PAUSE_HELP_1
Definition: resource.h:56
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define IDS_GENERIC_SYNTAX
Definition: resource.h:202
INT __cdecl ConPrintf(IN PCON_STREAM Stream, IN LPWSTR szStr,...)
Definition: outstream.c:520
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:576
smooth NULL
Definition: ftsmooth.c:416
#define OpenSCManager
Definition: winsvc.h:575
#define StdErr
Definition: stream.h:77
#define SERVICE_CONTROL_PAUSE
Definition: winsvc.h:37
INT ConResPuts(IN PCON_STREAM Stream, IN UINT uID)
Definition: outstream.c:610
static const WCHAR L[]
Definition: oid.c:1087
#define IDS_PAUSE_SYNTAX
Definition: resource.h:55
BOOL WINAPI ControlService(SC_HANDLE hService, DWORD dwControl, LPSERVICE_STATUS lpServiceStatus)
Definition: scm.c:618
#define StdOut
Definition: stream.h:76
INT cmdPause(INT argc, WCHAR **argv)
Definition: cmdPause.c:12
static SERVICE_STATUS status
Definition: service.c:31
#define SERVICE_PAUSE_CONTINUE
Definition: winsvc.h:59
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define IDS_PAUSE_HELP_2
Definition: resource.h:57