init
This commit is contained in:
63
Servers/游戏组件/万年麻将/游戏服务器/GameServer.cpp
Normal file
63
Servers/游戏组件/万年麻将/游戏服务器/GameServer.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
#include "Stdafx.h"
|
||||
#include <afxdllx.h>
|
||||
#include <strsafe.h>
|
||||
|
||||
void MyLog( TCHAR *szLog, ... )
|
||||
{
|
||||
FILE *pLogFile = NULL;
|
||||
static CString strFileName;
|
||||
if (strFileName.IsEmpty())
|
||||
{
|
||||
TCHAR *szPath=strFileName.GetBuffer(MAX_PATH);
|
||||
GetModuleFileName(AfxGetInstanceHandle(),szPath,MAX_PATH);
|
||||
PathRemoveFileSpec(szPath);
|
||||
StringCchCat(szPath,MAX_PATH, TEXT("\\万年麻将服务器日志.txt"));
|
||||
strFileName.ReleaseBuffer();
|
||||
}
|
||||
|
||||
pLogFile = _tfopen(strFileName.GetBuffer(), _T("a"));
|
||||
if(!pLogFile) return;
|
||||
|
||||
TCHAR szLogBuffer[2048]={0};
|
||||
TCHAR szCurrentDate[32] = { 0 };
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, szLog);
|
||||
_vstprintf_s(szLogBuffer, szLog, ap);
|
||||
va_end(ap);
|
||||
|
||||
SYSTEMTIME Systemtime;
|
||||
GetLocalTime(&Systemtime);
|
||||
_stprintf_s(szCurrentDate, _T("%d/%d/%d %2d:%2d:%2d"), Systemtime.wYear, Systemtime.wMonth, Systemtime.wDay, Systemtime.wHour, Systemtime.wMinute, Systemtime.wSecond);
|
||||
|
||||
#ifdef _UNICODE
|
||||
fwprintf(pLogFile, _T("[%s] %s\n"), szCurrentDate, szLogBuffer);
|
||||
#else
|
||||
fprintf(pLogFile, "[%s] %s\n", szCurrentDate, szLogBuffer);
|
||||
#endif
|
||||
|
||||
fflush(pLogFile);
|
||||
fclose(pLogFile);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static AFX_EXTENSION_MODULE GameServerDLL={NULL,NULL};
|
||||
|
||||
//DLL 导出主函数
|
||||
extern "C" int APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(lpReserved);
|
||||
if (dwReason==DLL_PROCESS_ATTACH)
|
||||
{
|
||||
if (!AfxInitExtensionModule(GameServerDLL, hInstance)) return 0;
|
||||
new CDynLinkLibrary(GameServerDLL);
|
||||
}
|
||||
else if (dwReason==DLL_PROCESS_DETACH)
|
||||
{
|
||||
AfxTermExtensionModule(GameServerDLL);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
Reference in New Issue
Block a user