⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 commfunc.cpp

📁 mapx 加地图vc mapx添加图元信息,地址翻译
💻 CPP
字号:
// CommFunc.cpp: implementation of the CCommFunc class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "CommFunc.h"
#include "WinSock.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

//20050729
//add by east 2007 10 25
CCommFunc g_CommFunc;

CCommFunc::CCommFunc()
{
	TCHAR szModule[_MAX_PATH];
	//Current Directory
	::GetCurrentDirectory(_MAX_PATH, szModule);
	this->m_szCurrentPath = szModule;
	this->m_szCurrentPath += DEF_DBLBACKLASH;
	//Execute Directory
	::GetModuleFileName(NULL, szModule, _MAX_PATH);
	this->m_szExecutePath = szModule;
	this->m_szExecutePath += DEF_DBLBACKLASH;
}

CCommFunc::~CCommFunc()
{

}

CString CCommFunc::GetCurrentPath()
{
	return this->m_szCurrentPath;
}

CString CCommFunc::GetExecutePath()
{
	return this->m_szExecutePath;
}

BOOL CCommFunc::IsFileExist(CString szFileName)
{
	CFileFind finder;
	
	if( szFileName.GetLength()==0 )
		return FALSE;
	
	BOOL bWorking = finder.FindFile(szFileName);
	while (bWorking)
	{
		bWorking = finder.FindNextFile();
		if (finder.IsDots())
			continue;
		
		if (finder.IsDirectory())
			return FALSE;
		else
			return TRUE;
	}
	finder.Close();
	
	return FALSE;
}

BOOL CCommFunc::IsDirExist(CString szFileName)
{
	CFileFind finder;
	
	if( szFileName.GetLength()==0 )
		return FALSE;

	if( !szFileName.Right(1).CompareNoCase(DEF_DBLBACKLASH) )
		szFileName = szFileName.Left(szFileName.GetLength()-1);
	
	BOOL bWorking = finder.FindFile(szFileName);
	while (bWorking)
	{
		bWorking = finder.FindNextFile();
		if (finder.IsDots())
			continue;
		
		if (finder.IsDirectory())
			return TRUE;
	}
	finder.Close();
	
	return FALSE;
}

int CCommFunc::GetDateRange(CString szDayStart, CString szDayEnd, double &dblSecond)
{
	char *pTime = (LPSTR)(LPCSTR)szDayStart;
	COleDateTime dtStart(atoi(pTime), atoi(pTime+5), atoi(pTime+8),
		atoi(pTime+11), atoi(pTime+14), atoi(pTime+17));
	pTime = (LPSTR)(LPCSTR)szDayEnd;
	COleDateTime dtEnd(atoi(pTime), atoi(pTime+5), atoi(pTime+8),
		atoi(pTime+11), atoi(pTime+14), atoi(pTime+17));
	COleDateTimeSpan Time_Elapsed = dtEnd-dtStart;
	if( Time_Elapsed.GetStatus()!=COleDateTimeSpan::valid )
		return -1;
	else
	{
		dblSecond = Time_Elapsed.GetTotalSeconds();
		return 0;
	}
}

BOOL CCommFunc::SplitString(CString szSplittedString,
							CStringArray *paArray, CString szSplitMask)
{
	ASSERT(paArray);
	if( !paArray )
		return FALSE;
	else
		return this->SplitString(szSplittedString, *paArray, szSplitMask);
}

BOOL CCommFunc::SplitString(CString szSplittedString,
							CStringArray &aArray, CString szSplitMask)
{//以“szSplitMask为界拆分字符串;
	CString szTemp;
	int iPosOld = 0;
	int iPos = 0;
	
	if( szSplitMask.IsEmpty() )
		return FALSE;
	
	aArray.RemoveAll();
	if( szSplittedString.IsEmpty() )
		return TRUE;
	szSplittedString += szSplitMask;
	while( iPosOld < szSplittedString.GetLength() )
	{
		iPos = szSplittedString.Find(szSplitMask, iPosOld);
		if( iPos == -1 )
			break;
		szTemp = szSplittedString.Mid(iPosOld, iPos-iPosOld);//赋值
		aArray.Add(szTemp);
		iPosOld = iPos+1;
	}
	
	return TRUE;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -