ReactOS 0.4.15-dev-7924-g5949c20
cmdStop.c File Reference
#include "net.h"
Include dependency graph for cmdStop.c:

Go to the source code of this file.

Functions

INT cmdStop (INT argc, WCHAR **argv)
 

Function Documentation

◆ cmdStop()

INT cmdStop ( INT  argc,
WCHAR **  argv 
)

Definition at line 12 of file cmdStop.c.

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 {
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 {
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],
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
68done:
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
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
void ConPrintf(FILE *fp, LPCWSTR psz,...)
Definition: fc.c:20
#define StdOut
Definition: fc.c:14
#define StdErr
Definition: fc.c:15
VOID PrintNetMessage(DWORD dwMessage)
Definition: main.c:239
VOID PrintMessageString(DWORD dwMessage)
Definition: main.c:120
static SERVICE_STATUS ServiceStatus
Definition: browser.c:22
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
unsigned long DWORD
Definition: ntddk_ex.h:95
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
#define argv
Definition: mplay32.c:18
#define L(x)
Definition: ntvdm.h:50
SC_HANDLE WINAPI OpenSCManagerW(LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, DWORD dwDesiredAccess)
Definition: scm.c:2068
BOOL WINAPI ControlService(SC_HANDLE hService, DWORD dwControl, LPSERVICE_STATUS lpServiceStatus)
Definition: scm.c:622
SC_HANDLE WINAPI OpenServiceW(SC_HANDLE hSCManager, LPCWSTR lpServiceName, DWORD dwDesiredAccess)
Definition: scm.c:2160
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:580
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
int32_t INT
Definition: typedefs.h:58
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define SC_MANAGER_ENUMERATE_SERVICE
Definition: winsvc.h:16
#define SERVICES_ACTIVE_DATABASE
Definition: winsvc.h:564
#define SERVICE_STOP
Definition: winsvc.h:58
#define SERVICE_CONTROL_STOP
Definition: winsvc.h:36

Referenced by CommandShell().