|
|
@@ -23,7 +23,6 @@ |
|
|
|
#ifdef WIN32
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
#include <tchar.h>
|
|
|
|
#include <strsafe.h>
|
|
|
|
|
|
|
|
#else
|
|
|
@@ -49,7 +48,18 @@ |
|
|
|
#ifdef WIN32
|
|
|
|
|
|
|
|
// Application main entry point for Windows.
|
|
|
|
int _tmain(int argc, TCHAR *argv[]) {
|
|
|
|
int main(int argc, char *argv[]) {
|
|
|
|
|
|
|
|
#ifdef DEBUG_LOG_FILE
|
|
|
|
std::ofstream logStream;
|
|
|
|
|
|
|
|
logStream.open(DEBUG_LOG_FILE, std::fstream::app);
|
|
|
|
logStream << "main. argc: " << argc << std::endl;
|
|
|
|
for (int i = 0; i < argc; i++) {
|
|
|
|
logStream << "arg " << i << ": '" << argv[i] << "'" << std::endl;
|
|
|
|
}
|
|
|
|
logStream.close();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
CodeDweller::Service &service = CodeDweller::Service::getInstance();
|
|
|
|
|
|
|
@@ -60,6 +70,17 @@ int _tmain(int argc, TCHAR *argv[]) { |
|
|
|
// Service entry point for Windows.
|
|
|
|
VOID WINAPI ServiceMain(DWORD argc, LPTSTR *argv) {
|
|
|
|
|
|
|
|
#ifdef DEBUG_LOG_FILE
|
|
|
|
std::ofstream logStream;
|
|
|
|
|
|
|
|
logStream.open(DEBUG_LOG_FILE, std::fstream::app);
|
|
|
|
logStream << "ServiceMain. argc: " << argc << std::endl;
|
|
|
|
for (unsigned int i = 0; i < argc; i++) {
|
|
|
|
logStream << "arg " << i << ": '" << argv[i] << "'" << std::endl;
|
|
|
|
}
|
|
|
|
logStream.close();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
CodeDweller::Service &service = CodeDweller::Service::getInstance();
|
|
|
|
|
|
|
|
return service.serviceMain(argc, argv);
|
|
|
@@ -140,7 +161,7 @@ namespace CodeDweller { |
|
|
|
std::ofstream logStream;
|
|
|
|
|
|
|
|
logStream.open(DEBUG_LOG_FILE, std::fstream::app);
|
|
|
|
logStream << "main. argc: " << argc << std::endl;
|
|
|
|
logStream << "Service::main. argc: " << argc << std::endl;
|
|
|
|
for (int i = 0; i < argc; i++) {
|
|
|
|
logStream << "arg " << i << ": '" << argv[i] << "'" << std::endl;
|
|
|
|
}
|
|
|
@@ -150,7 +171,7 @@ namespace CodeDweller { |
|
|
|
#ifdef WIN32
|
|
|
|
|
|
|
|
SERVICE_TABLE_ENTRY ServiceTable[] = {
|
|
|
|
{"", (LPSERVICE_MAIN_FUNCTION) ServiceMain},
|
|
|
|
{(LPTSTR) "", ServiceMain},
|
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
@@ -277,8 +298,6 @@ namespace CodeDweller { |
|
|
|
// executable name; append them to the object's argument list.
|
|
|
|
loadArguments(argc - 1, (char **) argv + 1);
|
|
|
|
|
|
|
|
DWORD Status = E_FAIL;
|
|
|
|
|
|
|
|
// Register the service control handler with the SCM.
|
|
|
|
serviceStatusHandle =
|
|
|
|
RegisterServiceCtrlHandler("", ServiceCtrlHandler);
|
|
|
@@ -334,7 +353,7 @@ namespace CodeDweller { |
|
|
|
// Change status to stopped.
|
|
|
|
serviceStatus.dwControlsAccepted = 0;
|
|
|
|
serviceStatus.dwCurrentState = SERVICE_STOPPED;
|
|
|
|
serviceStatus.dwWin32ExitCode = NO_ERROR;
|
|
|
|
serviceStatus.dwWin32ExitCode = status;
|
|
|
|
serviceStatus.dwCheckPoint = 0;
|
|
|
|
(void) SetServiceStatus(serviceStatusHandle, &serviceStatus);
|
|
|
|
|