2024-12-21 10:04:04 +08:00
// DnLauncher.cpp : Defines the class behaviors for the application.
//
# include "stdafx.h"
# include "DnLauncher.h"
# include "DnLauncherDlg.h"
# include "DnServiceModule.h"
# include "DnFIrstPatchDlg.h"
# include <locale.h>
# include <process.h>
# include "DnControlData.h"
# include <io.h>
# ifdef _USE_BITTORRENT
# include "WLibTorrent.h"
# endif // _USE_BITTORRENT
# ifdef _DEBUG
# define new DEBUG_NEW
# endif
# pragma comment( lib, "shlwapi.lib" )
// CDnLauncherApp
BEGIN_MESSAGE_MAP ( CDnLauncherApp , CWinApp )
ON_COMMAND ( ID_HELP , & CWinApp : : OnHelp )
END_MESSAGE_MAP ( )
int __cdecl DefautAllocHook ( int , void * , size_t , int , long , const unsigned char * , int )
{
return 1 ;
}
int __cdecl MyAllocHook ( int nAllocType , void * pvData , size_t nSize , int nBlockUse ,
long lRequest , const unsigned char * szFileName , int nLine )
{
if ( nAllocType = = _HOOK_ALLOC & & nSize = = 106 )
{
int a = 0 ;
}
return 1 ;
}
// The one and only CDnLauncherApp object
CDnLauncherApp theApp ;
CString g_szCmdLine ;
CString g_szOriginalCmdLine ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ġ<EFBFBD> <C4A1> <20> <> <EFBFBD> ؼ<EFBFBD> <20> ʱⰪ <20> <> <EFBFBD> <EFBFBD>
CString g_szCommandLinePatchURL ; // Ŀ<> ǵ<EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> PatchConfigList.xml<6D> <6C> <20> ִ<EFBFBD> <20> <> <EFBFBD> <EFBFBD> <20> ּҸ<D6BC> <20> <> <EFBFBD> <EFBFBD> <20> <> <20> <> <EFBFBD> <EFBFBD> (<28> <> <EFBFBD> <EFBFBD> )
int g_nInitErrorCode = 0 ; // <20> <> ó <20> ʱ<EFBFBD> ȭ <20> <> <20> <> <EFBFBD> <EFBFBD> <20> ڵ<EFBFBD>
extern CDnFistPatchDownloadThread * g_pFirstPatchDownloadThread ;
CDnFIrstPatchDlg g_FirstPatchDlg ;
HANDLE g_FirstPatchDlgHandle ;
extern FirstPatchReturn g_nFirstPatchErrorMessage ;
unsigned int WINAPI ShowFirstPatchDlg ( void * arg )
{
INT_PTR nResult = g_FirstPatchDlg . DoModal ( ) ;
return 0 ;
}
# ifndef _DEBUG
static const char g_szMutexName [ ] = " Global \\ ___DN___ " ;
HANDLE g_hMutex = NULL ;
# endif // _DEBUG
// CDnLauncherApp construction
CDnLauncherApp : : CDnLauncherApp ( )
{
# ifdef _USE_LOG
DeleteOldLogFile ( ) ;
UseLogFile ( ) ;
# endif // _USE_LOG
# ifdef _DEBUG
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 2005 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> TRACE <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> Ʈ<EFBFBD> <C6AE> <EFBFBD> ̱<EFBFBD> <CCB1> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ⋪<EFBFBD> <E28BAA> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> Ѵ <EFBFBD> .
_tsetlocale ( LC_ALL , _T ( " korean " ) ) ;
// _CrtSetAllocHook( MyAllocHook );
// _CrtSetBreakAlloc( 2599 );
# endif
}
CDnLauncherApp : : ~ CDnLauncherApp ( )
{
# ifndef _DEBUG
if ( g_hMutex )
{
CloseHandle ( g_hMutex ) ;
g_hMutex = NULL ;
}
# endif // _DEBUG
if ( g_pServiceModule )
g_pServiceModule - > Destroy ( ) ;
SAFE_DELETE ( g_pServiceModule ) ;
LogWnd : : DestroyLog ( ) ;
}
// CDnLauncherApp initialization
BOOL CDnLauncherApp : : InitInstance ( )
{
g_szOriginalCmdLine = g_szCmdLine = m_lpCmdLine ;
ParseCommandLine ( ) ; // Ŀ<> ǵ<EFBFBD> <20> <> <EFBFBD> <EFBFBD> <20> Ľ<EFBFBD>
//<2F> <> <EFBFBD> <EFBFBD> üũ
# ifndef _DEBUG
g_hMutex = : : OpenMutexA ( MUTEX_ALL_ACCESS , FALSE , g_szMutexName ) ;
if ( g_hMutex = = NULL )
{
g_hMutex = : : CreateMutexA ( NULL , FALSE , g_szMutexName ) ;
}
else
{
ErrorMessageBoxLog ( _S ( STR_ALEADY_RUN + DNPATCHINFO . GetLanguageOffset ( ) ) ) ;
return FALSE ;
}
# endif // _DEBUG
CHECK_ALIGNMENT ( ) ;
INITCOMMONCONTROLSEX InitCtrls ;
InitCtrls . dwSize = sizeof ( InitCtrls ) ;
InitCtrls . dwICC = ICC_WIN95_CLASSES ;
InitCommonControlsEx ( & InitCtrls ) ;
CWinApp : : InitInstance ( ) ;
AfxEnableControlContainer ( ) ;
SetRegistryKey ( _T ( " DragonNest Launcher " ) ) ;
// ErrorMessageBoxLog( g_szCmdLine );
// LogWnd::TraceLog( g_szCmdLine );
if ( InitLauncher ( ) )
{
CDnLauncherDlg * pDlg = CDnLauncherDlg : : CreateLauncherDlg ( ) ;
m_pMainWnd = pDlg ;
INT_PTR nResponse = pDlg - > DoModal ( ) ;
SAFE_DELETE ( pDlg ) ;
}
# ifdef _USE_BITTORRENT
WLibTorrent : : DestroyInstance ( ) ;
# endif // _USE_BITTORRENT
return FALSE ;
}
BOOL CDnLauncherApp : : InitLauncher ( )
{
LogWnd : : TraceLog ( L " InitLauncher Start! " ) ;
# ifdef _USE_SINGLE_CLIENT
if ( FindProcessName ( _T ( DNCLIENT_NAME ) ) ) // <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <20> ߿<EFBFBD> <DFBF> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD>
{
ErrorMessageBoxLog ( _S ( STR_CLIENT_ALEADY_RUN + DNPATCHINFO . GetLanguageOffset ( ) ) ) ;
g_nInitErrorCode = INIT_ERROR_CLIENT_ALEADY_RUN ;
return FALSE ;
}
# endif // _USE_SINGLE_CLIENT
# ifdef _FIRST_PATCH
if ( ! InitFirstPatchThread ( ) ) // FirstPatch<63> <68> Thread<61> <64> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> Ѵ <EFBFBD> .
{
return InitFail ( ) ;
}
# endif
if ( ! CheckDirectXVersion ( ) ) // DirectX <20> <> <EFBFBD> <EFBFBD> üũ
{
return InitFail ( ) ;
}
if ( DNPATCHINFO . Init ( ) ! = S_OK ) // PatchInfo <20> ʱ<EFBFBD> ȭ ( PatchConfigList.xml <20> ٿ<EFBFBD> , <20> Ľ<EFBFBD> , Ŭ<> <C5AC> <EFBFBD> ̾<EFBFBD> Ʈ <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> , xml<6D> <6C> <EFBFBD> <EFBFBD> )
{
return InitFail ( ) ;
}
# ifndef _USE_PARTITION_SELECT
if ( ! DNPATCHINFO . SetPatchInfo ( ) ) // PatchInfo <20> <> <EFBFBD> <EFBFBD> ( PatchConfigList.xml <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> κ<EFBFBD> <CEBA> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> , <20> Ķ<EFBFBD> <C4B6> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> , <20> <> ġ <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> ⼭ üũ )
{
return InitFail ( ) ;
}
# endif // _USE_PARTITION_SELECT
# if defined(_FIRST_PATCH)
# ifdef _USE_PARTITION_SELECT
DNPATCHINFO . LoadVersionData ( ) ; // <20> <> Ƽ <EFBFBD> <C6BC> <20> <> <EFBFBD> <EFBFBD> && <20> <> <EFBFBD> <EFBFBD> <20> о <EFBFBD> <D0BE> <EFBFBD> <EFBFBD> <EFBFBD> .
# endif
if ( DNFIRSTPATCHINFO . GetFirstPatchStatus ( ) = = DNFIRSTPATCHINFO . EM_FIRSTPATCH_OK )
{
if ( ! DNFIRSTPATCHINFO . SetPatchInfo ( ) ) // First Patch "<22> ʱ<EFBFBD> ȭ" & "<22> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> "
{
return InitFail ( ) ;
}
}
TerminateFirstPatchThread ( ) ; // * First Patch<63> <68> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> *
# endif // _FIRST_PATCH
# if defined( _USE_COMMAND_LINE ) // Ŀ<> ǵ<EFBFBD> <C7B5> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <20> <> <20> Ķ<EFBFBD> <C4B6> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> Ȩ<> <C8A8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD>
if ( g_szCmdLine . GetLength ( ) = = 0 )
{
ShellExecute ( NULL , L " open " , DNPATCHINFO . GetHomepageUrl ( ) , NULL , NULL , SW_SHOW ) ;
return FALSE ;
}
# endif // _USE_COMMAND_LINE
g_pServiceModule = DnServiceModule : : CreateServiceModule ( ) ;
if ( g_pServiceModule & & ! g_pServiceModule - > Initialize ( ) ) // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> ü<EFBFBD> <C3BC> Initialize
{
g_nInitErrorCode = INIT_ERROR_SERVICE_MODULE ;
return InitFail ( ) ;
}
if ( ! RemoveUsedFile ( ) ) // <20> <> ó <20> <> <EFBFBD> <EFBFBD> <20> <> <20> <> <EFBFBD> <EFBFBD> <20> ߴ <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <20> <> <20> <> ó <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ʈ <20> <> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> tmp <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD>
{
return InitFail ( ) ;
}
# ifdef _FIRST_PATCH
# if !defined(_TEST)
if ( g_nFirstPatchErrorMessage = = FPR_NEED_FULLPATCH )
{
// Ŭ<> <C5AC> <EFBFBD> ̾<EFBFBD> Ʈ <20> 缳ġ<E7BCB3> <C4A1> <20> <> <EFBFBD> <EFBFBD> . <20> ׳ <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŵ.
LogWnd : : TraceLog ( L " FirstPatch Failed / need Client Full Patch! " ) ;
LogWnd : : Log ( LogLevel : : Error , _T ( " FirstPatch Failed / Need Full Patch " ) ) ;
return InitFail ( ) ;
}
# endif // _TEST
# endif // _FIRST_PATCH
# ifdef _USE_BITTORRENT
if ( ! WLibTorrent : : GetInstance ( ) - > InitSession ( L " DN " ) )
{
g_nInitErrorCode = INIT_ERROR_BITTORRENT_SESSION ;
return InitFail ( ) ;
}
# endif // _USE_BITTORRENT
LogWnd : : TraceLog ( L " InitLauncher Success! " ) ;
return TRUE ;
}
# ifdef _FIRST_PATCH
BOOL CDnLauncherApp : : InitFirstPatchThread ( )
{
// * Tmp<6D> <70> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> .
if ( _access ( DNLAUNCHER_NAME_TMP , 0 ) = = 0 )
{
if ( ! ClientDeleteFile ( _T ( DNLAUNCHER_NAME_TMP ) ) )
{
LogWnd : : Log ( LogLevel : : Warning , _T ( " dnlauncher.tmp File Delete Failed " ) ) ;
}
}
// * FirstPatch <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ȳ<EFBFBD> <C8B2> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ִ<EFBFBD> Dialog Thread <20> <> <EFBFBD> <EFBFBD> *
g_FirstPatchDlgHandle = ( HANDLE ) _beginthreadex ( NULL , 0 , ShowFirstPatchDlg , NULL , 0 , NULL ) ;
if ( g_FirstPatchDlgHandle = = NULL )
{
LogWnd : : Log ( LogLevel : : Error , _T ( " FirstPatch Dialog Thread Create Failed " ) ) ;
return FALSE ;
}
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ġ<EFBFBD> <C4A1> <20> <> <EFBFBD> ۉ<EFBFBD> <DB89> <EFBFBD> .
DNFIRSTPATCHINFO . SetFirstPatchProcess ( DNFIRSTPATCHINFO . EM_FIRSTPATCH_ING ) ;
return TRUE ;
}
void CDnLauncherApp : : TerminateFirstPatchThread ( )
{
if ( g_pFirstPatchDownloadThread ) // <20> ٿ<EFBFBD> <D9BF> ε<EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> .
{
// FirstPatch<63> <68> <20> ٿ<EFBFBD> <20> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> 尡 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> .
WaitForSingleObject ( g_pFirstPatchDownloadThread - > GetThreadHandle ( ) , INFINITE ) ;
}
// <20> <> <EFBFBD> ̾<EFBFBD> <CCBE> α <EFBFBD> <20> <> <EFBFBD> <EFBFBD> .
if ( g_FirstPatchDlg )
{
// * FirstPatch<63> <68> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> ̾<EFBFBD> <CCBE> α <EFBFBD> & <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> * //
DWORD dwExitCode ;
if ( GetExitCodeThread ( g_FirstPatchDlgHandle , & dwExitCode ) )
{
TerminateThread ( g_FirstPatchDlgHandle , dwExitCode ) ;
}
g_FirstPatchDlg . EndDialog ( IDYES ) ;
}
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ġ<EFBFBD> <C4A1> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> .
DNFIRSTPATCHINFO . SetFirstPatchProcess ( DNFIRSTPATCHINFO . EM_FIRSTPATCH_NOT ) ;
}
# endif // _FIRST_PATCH
BOOL CDnLauncherApp : : InitFail ( )
{
CString strError ;
strError . Format ( _S ( STR_LAUNCHER_INIT_FAILED + DNPATCHINFO . GetLanguageOffset ( ) ) , g_nInitErrorCode ) ;
LogWnd : : Log ( LogLevel : : Error , strError ) ;
AfxMessageBox ( strError ) ;
# ifdef _FIRST_PATCH
HANDLE pHandles [ 2 ] ;
pHandles [ 0 ] = g_FirstPatchDlgHandle ;
if ( g_pFirstPatchDownloadThread )
{
pHandles [ 1 ] = g_pFirstPatchDownloadThread - > GetThreadHandle ( ) ;
}
DWORD dwExitCode ;
GetExitCodeThread ( g_FirstPatchDlgHandle , & dwExitCode ) ;
TerminateThread ( g_FirstPatchDlgHandle , dwExitCode ) ;
if ( WAIT_FAILED ! = WaitForMultipleObjects ( 2 , pHandles , TRUE , INFINITE ) )
{
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> 尡 <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> , <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ų<EFBFBD> <C5B2> .
return FALSE ;
}
# endif
return FALSE ;
}
BOOL CDnLauncherApp : : CheckDirectXVersion ( )
{
DWORD dwDirectXVersion = 0 ;
TCHAR strDirectXVersion [ 10 ] = { 0 , } ;
std : : wstring wstrVersion ;
int nResult = GetDXVersion ( & dwDirectXVersion , strDirectXVersion , 10 ) ;
CString szStr ;
LogWnd : : TraceLog ( _T ( " DirectX Version (%u) (%s) " ) , dwDirectXVersion , strDirectXVersion ) ;
if ( dwDirectXVersion < 0x00090000 )
{
wstrVersion = strDirectXVersion ;
if ( wstrVersion ! = L " 9.0c " )
{
CString szStr ;
szStr . Format ( _S ( STR_DX_LOW_VER + DNPATCHINFO . GetLanguageOffset ( ) ) , wstrVersion . c_str ( ) ) ;
ErrorMessageBoxLog ( szStr ) ;
g_nInitErrorCode = INIT_ERROR_DX_VER ;
return FALSE ;
}
}
return TRUE ;
}
void CDnLauncherApp : : ParseCommandLine ( )
{
if ( g_szCmdLine . GetLength ( ) = = 0 )
return ;
LPCTSTR szlpURL = L " http:// " ;
# ifdef _USE_MULTILANGUAGE
LPCTSTR szlpLanguage = L " language: " ;
# endif // _USE_MULTILANGUAGE
std : : wstring wszCmdLine ;
wszCmdLine = g_szCmdLine ;
std : : vector < std : : wstring > tokens ;
TokenizeW ( wszCmdLine , tokens , std : : wstring ( L " " ) ) ;
for ( DWORD i = 0 ; i < tokens . size ( ) ; i + + )
{
if ( NULL ! = StrStr ( tokens [ i ] . c_str ( ) , szlpURL ) ) // PatchConfigList.xml<6D> <6C> <20> ּҰ<D6BC> <20> <> <EFBFBD> <EFBFBD> <20> ִ<EFBFBD>
{
g_szCommandLinePatchURL = tokens [ i ] . c_str ( ) ; // <20> ּ<EFBFBD> <20> <> <EFBFBD> <EFBFBD>
g_szCmdLine . Replace ( g_szCommandLinePatchURL , L " " ) ; // Ŀ<> ǵ<EFBFBD> <20> <> <EFBFBD> ο <EFBFBD> <CEBF> <EFBFBD> <20> ּ<EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ش<EFBFBD>
# ifndef _USE_MULTILANGUAGE
break ;
# endif // _USE_MULTILANGUAGE
}
# ifdef _USE_MULTILANGUAGE
if ( NULL ! = StrStr ( tokens [ i ] . c_str ( ) , szlpLanguage ) ) // PatchConfigList.xml<6D> <6C> <20> ּҰ<D6BC> <20> <> <EFBFBD> <EFBFBD> <20> ִ<EFBFBD>
{
tokens [ i ] . erase ( 0 , tokens [ i ] . find ( L " : " ) + 1 ) ;
DNPATCHINFO . SetLanguageParam ( tokens [ i ] . c_str ( ) ) ;
}
# endif // _USE_MULTILANGUAGE
}
tokens . clear ( ) ;
if ( g_szCommandLinePatchURL . GetLength ( ) > 0 & & g_szCommandLinePatchURL . GetBuffer ( ) [ g_szCommandLinePatchURL . GetLength ( ) - 1 ] ! = ' / ' )
g_szCommandLinePatchURL + = ' / ' ;
}
void CDnLauncherApp : : DeleteOldLogFile ( )
{
TCHAR szCurFileName [ MAX_PATH ] = { 0 , } ;
: : GetModuleFileName ( NULL , szCurFileName , MAX_PATH ) ;
TCHAR szDrive [ MAX_PATH ] = { 0 , } ;
TCHAR szDir [ MAX_PATH ] = { 0 , } ;
TCHAR szFileName [ MAX_PATH ] = { 0 , } ;
TCHAR szExt [ MAX_PATH ] = { 0 , } ;
_tsplitpath ( szCurFileName , szDrive , szDir , szFileName , szExt ) ;
CString _szCurPath ;
_szCurPath . Format ( _T ( " %s%s \\ Log \\ " ) , szDrive , szDir ) ;
WIN32_FIND_DATA FindFileData ;
HANDLE hFind ;
CString szFindLogFile ;
szFindLogFile = _szCurPath ;
szFindLogFile + = " DNLauncher_*_Log.txt " ;
hFind = FindFirstFile ( szFindLogFile . GetBuffer ( ) , & FindFileData ) ;
std : : vector < CString > vecStrLogFileName ;
while ( hFind ! = INVALID_HANDLE_VALUE )
{
if ( ! ( FindFileData . dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) )
{
CString szLogFile ;
szLogFile = _szCurPath ;
szLogFile + = FindFileData . cFileName ;
vecStrLogFileName . push_back ( szLogFile ) ;
}
if ( ! FindNextFile ( hFind , & FindFileData ) ) break ;
}
FindClose ( hFind ) ;
std : : vector < CString > vecStrDeleteLogFileName ;
for ( int i = 0 ; i < static_cast < int > ( vecStrLogFileName . size ( ) ) ; i + + )
{
CString strTemp = vecStrLogFileName [ i ] ;
strTemp . Delete ( 0 , strTemp . Find ( L " _ " ) + 1 ) ;
int nIndex = strTemp . Find ( L " _ " ) ;
strTemp . Delete ( nIndex , strTemp . GetLength ( ) - nIndex ) ;
int nLogDate = _wtoi ( strTemp . GetBuffer ( ) ) ;
struct tm now ;
time_t systemTime ;
time ( & systemTime ) ; // <20> <> <EFBFBD> <EFBFBD> <20> ð<EFBFBD> <C3B0> <EFBFBD> <20> <> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD>
localtime_s ( & now , & systemTime ) ; // <20> <> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> ð<EFBFBD> <C3B0> <EFBFBD> <20> и<EFBFBD> <D0B8> Ͽ<EFBFBD> <20> <> <EFBFBD> <EFBFBD> ü<EFBFBD> <C3BC> <20> ֱ<EFBFBD>
TCHAR szCurDate [ 1024 ] ;
_sntprintf_s ( szCurDate , 1024 , _T ( " %04d%02d%02d " ) , 1900 + now . tm_year , now . tm_mon , now . tm_mday ) ; // <20> Ѵ <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <20> ͵<EFBFBD> <CDB5> <EFBFBD> <20> <> <EFBFBD> <EFBFBD>
int nCurDate = _wtoi ( szCurDate ) ;
if ( nLogDate < nCurDate )
{
vecStrDeleteLogFileName . push_back ( vecStrLogFileName [ i ] ) ;
}
}
for ( int i = 0 ; i < static_cast < int > ( vecStrDeleteLogFileName . size ( ) ) ; i + + )
{
ClientDeleteFile ( vecStrDeleteLogFileName [ i ] ) ;
}
vecStrLogFileName . clear ( ) ;
vecStrDeleteLogFileName . clear ( ) ;
}
void CDnLauncherApp : : UseLogFile ( )
{
TCHAR szCurFileName [ MAX_PATH ] = { 0 , } ;
: : GetModuleFileName ( NULL , szCurFileName , MAX_PATH ) ;
TCHAR szDrive [ MAX_PATH ] = { 0 , } ;
TCHAR szDir [ MAX_PATH ] = { 0 , } ;
TCHAR szFileName [ MAX_PATH ] = { 0 , } ;
TCHAR szExt [ MAX_PATH ] = { 0 , } ;
_tsplitpath ( szCurFileName , szDrive , szDir , szFileName , szExt ) ;
CString _szCurPath ;
_szCurPath . Format ( _T ( " %s%s \\ Log " ) , szDrive , szDir ) ;
if ( GetFileAttributes ( _szCurPath . GetBuffer ( ) ) ! = FILE_ATTRIBUTE_DIRECTORY )
CreateDirectory ( _szCurPath . GetBuffer ( ) , NULL ) ;
LogWnd : : CreateLog ( true , LogWnd : : LOG_TARGET_FILE ) ;
}
void CDnLauncherApp : : UseLogWindow ( )
{
TCHAR szCurFileName [ MAX_PATH ] = { 0 , } ;
: : GetModuleFileName ( NULL , szCurFileName , MAX_PATH ) ;
TCHAR szDrive [ MAX_PATH ] = { 0 , } ;
TCHAR szDir [ MAX_PATH ] = { 0 , } ;
TCHAR szFileName [ MAX_PATH ] = { 0 , } ;
TCHAR szExt [ MAX_PATH ] = { 0 , } ;
_tsplitpath ( szCurFileName , szDrive , szDir , szFileName , szExt ) ;
CString _szCurPath ;
_szCurPath . Format ( _T ( " %s%s \\ Log " ) , szDrive , szDir ) ;
if ( GetFileAttributes ( _szCurPath . GetBuffer ( ) ) ! = FILE_ATTRIBUTE_DIRECTORY )
CreateDirectory ( _szCurPath . GetBuffer ( ) , NULL ) ;
LogWnd : : CreateLog ( true , LogWnd : : LOG_TARGET_WINDOW ) ;
}
BOOL CDnLauncherApp : : RemoveUsedFile ( )
{
BOOL bRtn = TRUE ;
LogWnd : : TraceLog ( L " RemoveUsedFile " ) ;
if ( ClientDeleteFile ( _T ( DNLAUNCHER_NAME_TMP ) ) = = FALSE )
{
KillProcess ( _T ( DNLAUNCHER_NAME ) ) ; // <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> μ<EFBFBD> <CEBC> <EFBFBD> â<EFBFBD> <C3A2> <EFBFBD> <EFBFBD> dnlauncher.exe<78> <65> <20> <> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> Ų<EFBFBD> <C5B2> .
if ( ClientDeleteFile ( _T ( DNLAUNCHER_NAME_TMP ) ) = = FALSE )
bRtn = FALSE ;
}
if ( ClientDeleteFile ( PATCHCONFIG_LIST ) = = FALSE )
bRtn = FALSE ;
if ( ! bRtn )
g_nInitErrorCode = INIT_ERROR_REMOVE_FILE ;
return bRtn ;
}