mirror of
https://github.com/reactos/reactos.git
synced 2026-06-02 17:31:23 +08:00
Add information letting us know creation deletion of services has worked.
comment out testing debug info. svn path=/trunk/; revision=19042
This commit is contained in:
@@ -20,7 +20,8 @@ BOOL Control(DWORD Control, LPCTSTR ServiceName, LPCTSTR *Args)
|
||||
{
|
||||
SC_HANDLE hSc;
|
||||
SERVICE_STATUS Status;
|
||||
|
||||
|
||||
#ifdef SCDBG
|
||||
/* testing */
|
||||
_tprintf(_T("service to control - %s\n\n"), ServiceName);
|
||||
_tprintf(_T("command - %lu\n\n"), Control);
|
||||
@@ -30,7 +31,7 @@ BOOL Control(DWORD Control, LPCTSTR ServiceName, LPCTSTR *Args)
|
||||
printf("%s\n", *Args);
|
||||
Args++;
|
||||
}
|
||||
|
||||
#endif /* SCDBG */
|
||||
|
||||
hSc = OpenService(hSCManager, ServiceName,
|
||||
SERVICE_INTERROGATE | SERVICE_PAUSE_CONTINUE |
|
||||
@@ -46,7 +47,7 @@ BOOL Control(DWORD Control, LPCTSTR ServiceName, LPCTSTR *Args)
|
||||
|
||||
if (! ControlService(hSc, Control, &Status))
|
||||
{
|
||||
_tprintf(_T("controlService failed\n"));
|
||||
_tprintf(_T("[SC] controlService FAILED %lu:\n\n"), GetLastError());
|
||||
ReportLastError();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,8 @@ BOOL Create(LPCTSTR ServiceName, LPCTSTR *ServiceArgs)
|
||||
|
||||
if ((! ServiceName) || (! BinaryPathName))
|
||||
return CreateUsage();
|
||||
|
||||
|
||||
#ifdef SCDBG
|
||||
/* testing */
|
||||
printf("service to create - %s\n", ServiceName);
|
||||
printf("Binary path - %s\n", BinaryPathName);
|
||||
@@ -29,7 +30,7 @@ BOOL Create(LPCTSTR ServiceName, LPCTSTR *ServiceArgs)
|
||||
printf("%s\n", *Options);
|
||||
Options++;
|
||||
}
|
||||
|
||||
#endif
|
||||
hSc = CreateService(hSCManager,
|
||||
ServiceName,
|
||||
ServiceName,
|
||||
@@ -50,9 +51,8 @@ BOOL Create(LPCTSTR ServiceName, LPCTSTR *ServiceArgs)
|
||||
ReportLastError();
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
CloseServiceHandle(hSc);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
_tprintf(_T("[SC] CreateService SUCCESS\n"));
|
||||
CloseServiceHandle(hSc);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -15,8 +15,10 @@ BOOL Delete(LPCTSTR ServiceName)
|
||||
{
|
||||
SC_HANDLE hSc;
|
||||
|
||||
#ifdef SCDBG
|
||||
/* testing */
|
||||
printf("service to delete - %s\n\n", ServiceName);
|
||||
#endif
|
||||
|
||||
hSc = OpenService(hSCManager, ServiceName, DELETE);
|
||||
|
||||
@@ -34,6 +36,7 @@ BOOL Delete(LPCTSTR ServiceName)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
_tprintf(_T("[SC] DeleteService SUCCESS\n"));
|
||||
CloseServiceHandle(hSc);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -58,8 +58,12 @@ INT ScControl(LPTSTR MachineName, // remote machine name
|
||||
_tprintf(_T("Remote service control is not yet implemented\n"));
|
||||
return 2;
|
||||
}
|
||||
|
||||
hSCManager = OpenSCManager(MachineName, NULL, SC_MANAGER_ALL_ACCESS);
|
||||
|
||||
/* if we are emurating the services, we don't need administrator access */
|
||||
if ( (_tcsicmp(Command, _T("query")) == 0) || (_tcsicmp(Command, _T("queryex")) == 0) )
|
||||
hSCManager = OpenSCManager(MachineName, NULL, SC_MANAGER_ENUMERATE_SERVICE);
|
||||
else
|
||||
hSCManager = OpenSCManager(MachineName, NULL, SC_MANAGER_ALL_ACCESS);
|
||||
if (hSCManager == NULL)
|
||||
{
|
||||
_tprintf(_T("[SC] OpenSCManager FAILED %lu:\n\n"), GetLastError());
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
extern SC_HANDLE hSCManager; // declared in sc.c
|
||||
|
||||
//#define DBG
|
||||
//#define SCDBG
|
||||
|
||||
/* control functions */
|
||||
BOOL Query(LPCTSTR ServiceName, LPCTSTR *ServiceArgs, BOOL bExtended);
|
||||
|
||||
@@ -14,9 +14,10 @@
|
||||
BOOL Start(LPCTSTR ServiceName, LPCTSTR *ServiceArgs, INT ArgCount)
|
||||
{
|
||||
SC_HANDLE hSc;
|
||||
SERVICE_STATUS_PROCESS ServiceStatus;
|
||||
SERVICE_STATUS_PROCESS ServiceStatus, ServiceStatus2;
|
||||
DWORD BytesNeeded;
|
||||
|
||||
#ifdef SCDBG
|
||||
/* testing */
|
||||
_tprintf(_T("service to start - %s\n\n"), ServiceName);
|
||||
_tprintf(_T("Arguments :\n"));
|
||||
@@ -25,7 +26,7 @@ BOOL Start(LPCTSTR ServiceName, LPCTSTR *ServiceArgs, INT ArgCount)
|
||||
printf("%s\n", *ServiceArgs);
|
||||
ServiceArgs++;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* get a handle to the service requested for starting */
|
||||
hSc = OpenService(hSCManager, ServiceName, SERVICE_ALL_ACCESS);
|
||||
@@ -40,7 +41,7 @@ BOOL Start(LPCTSTR ServiceName, LPCTSTR *ServiceArgs, INT ArgCount)
|
||||
/* start the service opened */
|
||||
if (! StartService(hSc, ArgCount, ServiceArgs))
|
||||
{
|
||||
_tprintf(_T("StartService failed\n"));
|
||||
_tprintf(_T("[SC] StartService FAILED %lu:\n\n"), GetLastError());
|
||||
ReportLastError();
|
||||
return FALSE;
|
||||
}
|
||||
@@ -77,11 +78,22 @@ BOOL Start(LPCTSTR ServiceName, LPCTSTR *ServiceArgs, INT ArgCount)
|
||||
}
|
||||
}
|
||||
|
||||
QueryServiceStatusEx(hSc, SC_STATUS_PROCESS_INFO, (LPBYTE)&ServiceStatus2,
|
||||
sizeof(SERVICE_STATUS_PROCESS), &BytesNeeded);
|
||||
|
||||
CloseServiceHandle(hSc);
|
||||
|
||||
if (ServiceStatus.dwCurrentState == SERVICE_RUNNING)
|
||||
{
|
||||
_tprintf(_T("%s is running\n"), ServiceName);
|
||||
_tprintf(_T("\nSERVICE_NAME: %s\n"), ServiceName);
|
||||
_tprintf(_T("\tTYPE : %lu\n"), ServiceStatus2.dwServiceType);
|
||||
_tprintf(_T("\tSTATE : %lu\n"), ServiceStatus2.dwCurrentState);
|
||||
_tprintf(_T("\tWIN32_EXIT_CODE : %lu\n"), ServiceStatus2.dwWin32ExitCode);
|
||||
_tprintf(_T("\tCHECKPOINT : %lu\n"), ServiceStatus2.dwCheckPoint);
|
||||
_tprintf(_T("\tWAIT_HINT : %lu\n"), ServiceStatus2.dwWaitHint);
|
||||
_tprintf(_T("\tPID : %lu\n"), ServiceStatus2.dwProcessId);
|
||||
_tprintf(_T("\tFLAGS : %lu\n"), ServiceStatus2.dwServiceFlags);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user