64 lines
1.6 KiB
C++
64 lines
1.6 KiB
C++
|
|
#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("\\<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>齫<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־.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 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
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;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//////////////////////////////////////////////////////////////////////////
|