浏览代码

Change _tmain to main.

git-svn-id: https://svn.microneil.com/svn/CodeDweller/branches/adeniz_1@41 d34b734f-a00e-4b39-a726-e4eeb87269ab
adeniz_1
adeniz 10 年前
父节点
当前提交
4cd5ce48db
共有 2 个文件被更改,包括 28 次插入9 次删除
  1. 26
    7
      service.cpp
  2. 2
    2
      service.hpp

+ 26
- 7
service.cpp 查看文件

@@ -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);

+ 2
- 2
service.hpp 查看文件

@@ -39,7 +39,7 @@

#ifdef WIN32

int _tmain(int argc, TCHAR *argv[]);
int main(int argc, char *argv[]);

VOID WINAPI ServiceMain(DWORD argc, LPTSTR *argv);

@@ -274,7 +274,7 @@ namespace CodeDweller {
/// Handle for accessing service status on the OS.
SERVICE_STATUS_HANDLE serviceStatusHandle = NULL;

friend int ::_tmain(int argc, TCHAR *argv[]);
friend int ::main(int argc, char *argv[]);

friend VOID WINAPI ::ServiceMain(DWORD argc, LPTSTR *argv);


正在加载...
取消
保存