📄 updateinfo.cpp
字号:
#include ".\updateinfo.h"
#include <io.h>
CUpdateInfo::CUpdateInfo(void)
{
}
CUpdateInfo::~CUpdateInfo(void)
{
}
//INI 颇老篮 馆靛矫 角青 颇老(葛碘)捞 乐绰镑俊 鞍捞 乐绢具 茄促.
BOOL CUpdateInfo::LoadData()
{
char szDirPath[256], szFilePath[256];
GetModuleDirectory( szDirPath, 256 );
wsprintf( szFilePath, "%s%s", szDirPath, "updateinfo.ini" );
if( _access(szFilePath, 0) != -1 ) //颇老捞 粮犁窍搁..
{
LoadFTPInfo( szFilePath );
LoadRTTAInfo( szFilePath );
LoadUpdateInfo( szFilePath );
LoadProcessInfo( szFilePath );
LoadDownloadPath( szFilePath );
}
else
return FALSE;
return TRUE;
}
void CUpdateInfo::GetModuleDirectory( char* szDirPath, int nSize )
{
ZeroMemory( szDirPath, nSize );
char szPath[128];
char szDrive[40], szDir[256];
GetModuleFileName( NULL, szPath, 128);
_splitpath( szPath, szDrive, szDir, NULL, NULL);
wsprintf( szDirPath, "%s%s", szDrive, szDir);
}
void CUpdateInfo::LoadFTPInfo( const char* pszFilePath )
{
ZeroMemory( m_szFTP_IP, DEFAULT_BUFFER_SIZE );
GetPrivateProfileString( "FTP", "IP", "127.0.0.1", m_szFTP_IP, DEFAULT_BUFFER_SIZE, pszFilePath );
m_nFTP_Port = GetPrivateProfileInt( "FTP", "PORT", 21, pszFilePath );
ZeroMemory( m_szFTP_VersionFileName, DEFAULT_BUFFER_SIZE );
GetPrivateProfileString( "FTP", "VERSION_FILE", "wz_version.dat", m_szFTP_VersionFileName, 128, pszFilePath );
ZeroMemory( m_szFTP_FileListFileName, DEFAULT_BUFFER_SIZE );
GetPrivateProfileString( "FTP", "FILELIST_FILE ", "wz_filelist.dat", m_szFTP_FileListFileName, 128, pszFilePath );
}
void CUpdateInfo::LoadRTTAInfo( const char* pszFilePath )
{
ZeroMemory( m_szRTTA_IP, DEFAULT_BUFFER_SIZE );
GetPrivateProfileString( "RTTA", "IP", "127.0.0.1", m_szRTTA_IP, DEFAULT_BUFFER_SIZE, pszFilePath );
m_nRTTA_Port = GetPrivateProfileInt( "RTTA", "PORT", 20510, pszFilePath );
}
void CUpdateInfo::LoadUpdateInfo( const char* pszFilePath )
{
ZeroMemory( m_szServerName, MAX_SERVER_COUNT*DEFAULT_BUFFER_SIZE );
ZeroMemory( m_szServerVer, MAX_SERVER_COUNT*DEFAULT_BUFFER_SIZE );
m_nCntServer = GetPrivateProfileInt( "UPDATE_DATA", "COUNT", 0, pszFilePath );
for(int i = 0; i < m_nCntServer; i++)
{
char szNum[10];
wsprintf(szNum, "%d", i+1);
//1. 辑滚捞抚
string strServer = "SERVER";
strServer += szNum;
GetPrivateProfileString( "UPDATE_DATA", strServer.c_str(), "", m_szServerName[i], DEFAULT_BUFFER_SIZE, pszFilePath );
//2. 辑滚滚傈
string strVersion = "VERSION";
strVersion += szNum;
GetPrivateProfileString( "UPDATE_DATA", strVersion.c_str(), "", m_szServerVer[i], DEFAULT_BUFFER_SIZE, pszFilePath );
}
}
BOOL CUpdateInfo::SaveVersionInfo( byte byVer1, byte byVer2, byte byVer3, int nServerNumber )
{
char szDirPath[256], szFilePath[256];
GetModuleDirectory( szDirPath, 256 );
wsprintf( szFilePath, "%s%s", szDirPath, "updateinfo.ini" );
if( _access(szFilePath, 0) != -1 ) //颇老捞 粮犁窍搁..
{
char szTemp[10], szVer[128];
wsprintf(szTemp, "%02d.%02d.%02d", byVer1, byVer2, byVer3);
wsprintf(szVer, "Version%d", nServerNumber+1);
BOOL bRet = WritePrivateProfileString ("UPDATE_DATA", szVer, szTemp, szFilePath);
if( bRet == FALSE )
{
DWORD dwError = GetLastError();
if( dwError == 5 ) //立辟 阂啊瓷..
{
SetFileAttributes( szFilePath, FILE_ATTRIBUTE_NORMAL );
WritePrivateProfileString ("UPDATE_DATA", szVer, szTemp, szFilePath);
}
}
}
else
return FALSE;
return TRUE;
}
void CUpdateInfo::LoadProcessInfo( const char* pszFilePath )
{
//PROCESS
for(int i = 0; i < MAX_LIVE_PROCESS; i++)
{
string strProcess = "PROCESS";
char szNum[10];
wsprintf(szNum, "%d", i+1);
strProcess += szNum;
ZeroMemory( m_szProcess[i], DEFAULT_BUFFER_SIZE );
GetPrivateProfileString( "PROCESS", strProcess.c_str(), "", m_szProcess[i], DEFAULT_BUFFER_SIZE, pszFilePath );
}
}
void CUpdateInfo::LoadDownloadPath( const char* pszFilePath )
{
//DownloadPath
ZeroMemory( m_szDownloadPath, MAX_PATH_SIZE );
GetPrivateProfileString( "DOWNLOAD", "PATH", "C:\\SUN\\", m_szDownloadPath, MAX_PATH_SIZE, pszFilePath );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -