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

📄 global.cpp

📁 中国电信文字短信收发程序。采用电信提供的接口动态库。
💻 CPP
字号:
#include "stdafx.h"
#include "DataStruct.h"

TGlobalVar GlobalVar;
/////////////////////////////////////////////////
//Below is Global function
bool IsFileExists(CString FileName)
{
	WIN32_FIND_DATA FindFileData;
	HANDLE hFind;
	hFind = FindFirstFile(FileName, &FindFileData);
	if (hFind == INVALID_HANDLE_VALUE) return false;
	FindClose(hFind);
	return true;	
}
void WriteLogFile(CString str)
{
	FILE *stream;
	char *strLog ;
	char Segmentation[] = "====================================================================" ;
	char c = '\n';
	int strLen = str.GetLength();
	strLog = str.GetBuffer(0) ;
	if ( (stream = fopen(GlobalVar.FilePath.AppLogFile,"a" )) != NULL )
	{
		COleDateTime CurrentTime;
		CurrentTime = COleDateTime::GetCurrentTime();
		CString strFormat = _T("");
		strFormat = CurrentTime.Format(_T("%H,%M,%S,%A, %B %d, %Y"));
		fprintf( stream,"%s%c",Segmentation,c);
		fprintf( stream,"%s%c" ,strFormat,c);
		fprintf( stream, "%s%c", strLog, c );
		fclose( stream );
	}
}
CString ReadIni(CString SectionName, CString VarName)
{
	CString strReturn = _T("");
	GetPrivateProfileString(SectionName,VarName,"",strReturn.GetBuffer(255),255,GlobalVar.FilePath.IniFile);
	return strReturn ;
}
bool IsIniLogExists()
{
	char Temp[255];
	CString strPath = _T("");
	CString File = _T("");

	VERIFY(::GetModuleFileName(AfxGetInstanceHandle(),Temp, _MAX_PATH));
	strPath.Format("%s",Temp);
	strPath = strPath.Left(strPath.ReverseFind('\\')+1);

	//给全局变量赋值
	GlobalVar.FilePath.AppPath=strPath;

	File=strPath+"SysIni.ini";
	GlobalVar.FilePath.IniFile=File;//保存全局的配置文件名字
	if (!IsFileExists(File))
	{
		AfxMessageBox("配置文件不存在,请仔细检查!");
		return false;
	}
	
	File = strPath+"App.log";
	GlobalVar.FilePath.AppLogFile=File;//保存全局的日志文件名字
	if (!IsFileExists(File))
	{
		AfxMessageBox("日志文件不存在,请仔细检查!");
		return false;
	}
	return true;
}

⌨️ 快捷键说明

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