📄 cmpp.cpp
字号:
// cmpp.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "cmpp.h"
#include "service.h"
#include <winsvc.h>
#include "DeliverThread.h"
#include "ServerThread.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// The one and only application object
CWinApp theApp;
using namespace std;
extern char CMPP_INI_FILE[100];
extern char WEIMA[100];
extern char WEIMANEW[100];
CServerThread g_stServerThread;
CDeliverThread g_stDeliverThread;
VOID ServiceStart (DWORD dwArgc, LPTSTR *lpszArgv)
{
///////////////////////////////////////////////////
//
// Service initialization
//
// report the status to the service control manager.
//
if (!ReportStatusToSCMgr(
SERVICE_START_PENDING, // service state
NO_ERROR, // exit code
3000)) // wait hint
goto cleanup;
// report the status to the service control manager.
//
if (!ReportStatusToSCMgr(
SERVICE_START_PENDING, // service state
NO_ERROR, // exit code
3000)) // wait hint
goto cleanup;
// report the status to the service control manager.
//
if (!ReportStatusToSCMgr(
SERVICE_START_PENDING, // service state
NO_ERROR, // exit code
3000)) // wait hint
goto cleanup;
// report the status to the service control manager.
//
if (!ReportStatusToSCMgr(
SERVICE_START_PENDING, // service state
NO_ERROR, // exit code
3000)) // wait hint
goto cleanup;
if (!AfxSocketInit())
goto cleanup;
// report the status to the service control manager.
//
if (!ReportStatusToSCMgr(
SERVICE_RUNNING, // service state
NO_ERROR, // exit code
0)) // wait hint
goto cleanup;
//
// End of initialization
//
////////////////////////////////////////////////////////
LoadIni();
g_stDeliverThread.InitInstance();
Sleep(2000);
g_stServerThread.InitInstance();
g_stServerThread.Run();
////////////////////////////////////////////////////////
//
// Service is now running, perform work until shutdown
//
// g_stTransFile.StartTransFile();
cleanup:
return;
}
//
// FUNCTION: ServiceStop
//
// PURPOSE: Stops the service
//
// PARAMETERS:
// none
//
// RETURN VALUE:
// none
//
// COMMENTS:
// If a ServiceStop procedure is going to
// take longer than 3 seconds to execute,
// it should spawn a thread to execute the
// stop code, and return. Otherwise, the
// ServiceControlManager will believe that
// the service has stopped responding.
//
VOID ServiceStop()
{
g_stDeliverThread.g_bDeliverThreadExit = true;
g_stServerThread.g_bServerThreadExit = true;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -