123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- // stdafx.cpp : 只包括标准包含文件的源文件
- // lyfzRepair.pch 将作为预编译头
- // stdafx.obj 将包含预编译类型信息
- #include "stdafx.h"
- BOOL g_bClassicVer = TRUE;
- TCHAR g_szModelPath[MAX_PATH] = { 0 };
- CHAR g_szServerIPAddress[MAX_PATH] = { 0 };
- DWORD g_dwServerPort = 0;
- CHAR g_szClassicIPAddress[MAX_PATH] = { 0 };
- DWORD g_dwClassicPort = 0;
- void GetServerInfo()
- {
- CHAR szDrive[_MAX_DRIVE] = { 0 };
- CHAR szDir[_MAX_DIR] = { 0 };
- CHAR szFna[_MAX_DIR] = { 0 };
- CHAR szExt[_MAX_DIR] = { 0 };
- CHAR szModelPath[MAX_PATH] = { 0 };
- ::GetModuleFileNameA(NULL, szModelPath, sizeof(szModelPath));
- _splitpath_s(szModelPath, szDrive, szDir, szFna, szExt);
- strcpy_s(szModelPath, szDrive);
- strcat_s(szModelPath, szDir);
- CHAR szConfigFile[MAX_PATH] = { 0 };
- sprintf_s(szConfigFile, "%sConfig\\System.config", szModelPath);
- if (PathFileExistsA(szConfigFile))
- {
- // 加载xml文件;
- tinyxml2::XMLDocument xml;
- if (tinyxml2::XML_SUCCESS == xml.LoadFile(szConfigFile))
- {
- tinyxml2::XMLElement *pRootNode = xml.RootElement();
- if (stricmp(pRootNode->Name(), "xs:schema") == 0)
- {
- pRootNode = pRootNode->FirstChildElement();
- }
- if (pRootNode)
- {
- tinyxml2::XMLElement *pResultCode = pRootNode->FirstChildElement();
- while (pResultCode)
- {
- if (stricmp(pResultCode->Name(), "ServerPort") == 0)
- {
- g_dwServerPort = atoi(pResultCode->GetText());
- }
- if (stricmp(pResultCode->Name(), "ServerHostOrIP") == 0)
- {
- sprintf_s(g_szServerIPAddress, pResultCode->GetText());
- }
- pResultCode = pResultCode->NextSiblingElement();
- }
- }
- else
- {
- utility::WriteTextLog(_T("%s 加载头结点失败"), szConfigFile);
- }
- }
- else
- {
- utility::WriteTextLog(_T("%s 加载失败"), szConfigFile);
- }
- xml.Clear();
- }
- else
- {
- utility::WriteTextLog(_T("%s 不存在"), szConfigFile);
- }
- sprintf_s(szConfigFile, "%sHostInfo.ini", szModelPath);
- if ( PathFileExistsA(szConfigFile) )
- {
- // 获取服务器端TCP信息;
- GetPrivateProfileStringA("NetWorkInfo", "Host", "", g_szClassicIPAddress, MAX_PATH, szConfigFile);
- g_dwClassicPort = GetPrivateProfileIntA("NetWorkInfo", "CSPort", 0, szConfigFile);
- }
- }
- void GetModelPath()
- {
- TCHAR szDrive[_MAX_DRIVE] = { 0 };
- TCHAR szDir[_MAX_DIR] = { 0 };
- TCHAR szFna[_MAX_DIR] = { 0 };
- TCHAR szExt[_MAX_DIR] = { 0 };
- //TCHAR szModelPath[MAX_PATH] = { 0 };
- ::GetModuleFileName(NULL, g_szModelPath, sizeof(g_szModelPath));
- _tsplitpath_s(g_szModelPath, szDrive, szDir, szFna, szExt);
- _tcscpy_s(g_szModelPath, szDrive);
- _tcscat_s(g_szModelPath, szDir);
- }
|