ReactOS  0.4.14-dev-52-g6116262
cmdStop.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/cmdStop.c
5  * PURPOSE:
6  *
7  * PROGRAMMERS: Magnus Olsen (greatlord@reactos.org)
8  */
9 
10 #include "net.h"
11 
13 {
14  SC_HANDLE hManager = NULL;
15  SC_HANDLE hService = NULL;
17  DWORD dwError = ERROR_SUCCESS;
18  INT nError = 0;
19  INT i;
20 
21  if (argc != 3)
22  {
23  PrintMessageString(4381);
24  ConPuts(StdOut, L"\n");
25  PrintNetMessage(MSG_STOP_SYNTAX);
26  return 1;
27  }
28 
29  for (i = 2; i < argc; i++)
30  {
31  if (_wcsicmp(argv[i], L"/help") == 0)
32  {
33  PrintMessageString(4381);
34  ConPuts(StdOut, L"\n");
35  PrintNetMessage(MSG_STOP_SYNTAX);
36  PrintNetMessage(MSG_STOP_HELP);
37  return 1;
38  }
39  }
40 
41  hManager = OpenSCManagerW(NULL,
44  if (hManager == NULL)
45  {
46  dwError = GetLastError();
47  nError = 1;
48  goto done;
49  }
50 
51  hService = OpenServiceW(hManager,
52  argv[2],
53  SERVICE_STOP);
54  if (hService == NULL)
55  {
56  dwError = GetLastError();
57  nError = 1;
58  goto done;
59  }
60 
62  {
63  dwError = GetLastError();
64  nError = 1;
65  goto done;
66  }
67 
68 done:
69  if (hService != NULL)
70  CloseServiceHandle(hService);
71 
72  if (hManager != NULL)
73  CloseServiceHandle(hManager);
74 
75  if (dwError != ERROR_SUCCESS)
76  {
77  /* FIXME: Print proper error message */
78  ConPrintf(StdErr, L"Error: %lu\n", dwError);
79  }
80 
81  return nError;
82 }
static int argc
Definition: ServiceArgs.c:12
#define SC_MANAGER_ENUMERATE_SERVICE
Definition: winsvc.h:16
#define ERROR_SUCCESS
Definition: deptool.c:10
#define SERVICES_ACTIVE_DATABASE
Definition: winsvc.h:564
static SERVICE_STATUS ServiceStatus
Definition: dcomlaunch.c:27
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
VOID PrintNetMessage(DWORD dwMessage)
Definition: main.c:228
#define argv
Definition: mplay32.c:18
int32_t INT
Definition: typedefs.h:56
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
SC_HANDLE WINAPI OpenServiceW(SC_HANDLE hSCManager, LPCWSTR lpServiceName, DWORD dwDesiredAccess)
Definition: scm.c:2103
INT __cdecl ConPrintf(IN PCON_STREAM Stream, IN LPWSTR szStr,...)
Definition: outstream.c:520
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:577
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define StdErr
Definition: stream.h:77
static const WCHAR L[]
Definition: oid.c:1250
SC_HANDLE WINAPI OpenSCManagerW(LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, DWORD dwDesiredAccess)
Definition: scm.c:2011
INT cmdStop(INT argc, WCHAR **argv)
Definition: cmdStop.c:12
VOID PrintMessageString(DWORD dwMessage)
Definition: main.c:109
#define SERVICE_STOP
Definition: winsvc.h:58
BOOL WINAPI ControlService(SC_HANDLE hService, DWORD dwControl, LPSERVICE_STATUS lpServiceStatus)
Definition: scm.c:619
INT ConPuts(IN PCON_STREAM Stream, IN LPWSTR szStr)
Definition: outstream.c:427
#define StdOut
Definition: stream.h:76
#define SERVICE_CONTROL_STOP
Definition: winsvc.h:36
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)