2 * ReactOS SC - service control console program
6 * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 int sc_Lock(SC_HANDLE hSCManager
)
31 dprintf("sc_Lock(%x) - not implemented.\n", hSCManager
);
35 int sc_QueryLock(SC_HANDLE hSCManager
)
37 QUERY_SERVICE_LOCK_STATUS LockStatus
;
38 DWORD cbBufSize
= sizeof(QUERY_SERVICE_LOCK_STATUS
);
41 dprintf("sc_QueryLock() - called.\n");
43 if (QueryServiceLockStatus(hSCManager
, &LockStatus
, cbBufSize
, &cbBytesNeeded
)) {
46 dprintf("Failed to Query Service Lock Status.\n");
50 if (!CloseServiceHandle(hSCManager
)) {
51 dprintf("Failed to CLOSE handle to SCM.\n");
58 int sc_control(SC_HANDLE hSCManager
, char* service
, DWORD dwControl
)
62 SERVICE_STATUS serviceStatus
;
64 dprintf("sc_control(%x, %s, %d) - called.\n", hSCManager
, service
, dwControl
);
66 schService
= OpenServiceA(hSCManager
, service
, SERVICE_ALL_ACCESS
);
67 if (schService
!= NULL
) {
68 ret
= ControlService(schService
, dwControl
, &serviceStatus
);
69 dprintf("ControlService(%x, %x, %x) returned %d\n", schService
, dwControl
, &serviceStatus
, ret
);
74 CloseServiceHandle(schService
);
79 int sc_command(SC_HANDLE hSCManager
, SC_CMDS sc_cmd
, char* argv
[])
81 // dprintf("sc_command(%x, %d, %s) - called.\n", hSCManager, sc_cmd, argv[]);
84 //return sc_control(hSCManager, sc_cmd_arg, SERVICE_CONTROL_START);
85 dprintf(" - not implemented.\n");
88 return sc_control(hSCManager
, argv
[0], SERVICE_CONTROL_PAUSE
);
89 case SC_CMD_INTERROGATE
:
90 return sc_control(hSCManager
, argv
[0], SERVICE_CONTROL_INTERROGATE
);
92 return sc_control(hSCManager
, argv
[0], SERVICE_CONTROL_CONTINUE
);
94 return sc_control(hSCManager
, argv
[0], SERVICE_CONTROL_STOP
);
96 // case SC_CMD_CONFIG:
97 // case SC_CMD_DESCRIPTION:
98 // case SC_CMD_CONTROL:
101 return sc_Lock(hSCManager
);
102 case SC_CMD_QUERYLOCK
:
103 return sc_QueryLock(hSCManager
);
105 dprintf("sc_command(%x, %d, %s) - unknown command.\n", hSCManager
, sc_cmd
, argv
[0]);