최종완료보고 버전

This commit is contained in:
CodeTempla
2026-05-20 03:08:08 +09:00
commit 10d255ed51
548 changed files with 435582 additions and 0 deletions
+111
View File
@@ -0,0 +1,111 @@
#ifdef _WIN32
#include "huslib/huslib.h"
#include "huslib/huslibex.h"
#include <windows.h>
#ifdef _DEBUG
#include <crtdbg.h>
#endif // _DEBUG
#include "windows/WinService.h"
#define WRITE_MINI_DUMP
#if defined(_WIN32) && !defined(_DEBUG) && defined(WRITE_MINI_DUMP)
#include "windows/DebugAssist.h"
#endif // WRITE_MINI_DUMP
#else
#include <signal.h>
#endif // _WIN32
#include <stdio.h>
#include "Object.h"
#include "HusApp.h"
HApp * HApp::m_pApp = NULL;
HApp::HApp()
{
m_pApp = this;
}
///////////////////////////////////////
#ifdef _WIN32
#define TIMEOUT_SERVICE_START_PENDING 5000
VOID ServiceStart(DWORD nArgc, LPTSTR *pArgv, BOOL bConsoleMode)
{
#if defined(_WIN32) && !defined(_DEBUG)
InitialDumpWriting(); // for Windows Dump File
#endif
#ifdef _DEBUG
_CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF | _CRTDBG_ALLOC_MEM_DF);
#endif // _DEBUG
WSADATA wsaData;
WORD wVersionRequested = MAKEWORD(2, 2);
if (WSAStartup(wVersionRequested, &wsaData) != 0)
{
printf("[ERROR] Windows sockets initialization failed. WSAGetLastError = %d\n", WSAGetLastError());
return;
}
if (LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 2)
{
printf("[ERROR] Could not find a usable WinSock DLL.\n");
WSACleanup();
return;
}
if (!ReportStatusToSCMgr(SERVICE_START_PENDING, NO_ERROR, TIMEOUT_SERVICE_START_PENDING))
return;
if (!ReportStatusToSCMgr(SERVICE_RUNNING, NO_ERROR, 0))
return;
HApp::m_pApp->OnMain(nArgc, pArgv);
WSACleanup();
}
VOID ServiceStop()
{
HApp::m_pApp->OnExit(0);
if (!ReportStatusToSCMgr(SERVICE_STOP_PENDING, NO_ERROR, TIMEOUT_SERVICE_START_PENDING))
return;
if (!ReportStatusToSCMgr(SERVICE_STOPPED, NO_ERROR, 0))
return;
}
#endif // _WIN32
int main(int nArgc, char ** pArgv)
{
if (HApp::m_pApp == NULL)
{
printf("ERROR: Can't find an object that derives from HApp.\n");
return 0;
}
#ifdef _WIN32
WinServiceMain(nArgc, pArgv);
return 0;
#else
signal(SIGPIPE, SIG_IGN);
#endif // _WIN32
return HApp::m_pApp->OnMain(nArgc, pArgv);
}