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

📄 config.cpp

📁 PDA通讯网关服务器源码程序
💻 CPP
字号:
// Config.cpp: implementation of the CCfg class.
//
//////////////////////////////////////////////////////////////////////


#include "stdafx.h" 
#include "Config.h"
#include "PubConst.h"

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

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

CCfg::CCfg()
{
}

CCfg::~CCfg()
{

}

//读出字符串
BOOL CCfg::OnReadCfg(LPCTSTR Section, LPCTSTR Name, char *pchValue)
{
	GetPrivateProfileString(Section, Name,"nofind",pchValue,50,pchConfigFile);
	if (pchValue==STR_NOFIND)
	{
		return FALSE;
	}
	return TRUE;	
}

//读出字符串,用CString
BOOL CCfg::OnReadCfg(LPCTSTR Section, LPCTSTR Name, CString  &strValue)
{
	char chValue[50]={0};
	GetPrivateProfileString(Section, Name,"nofind",chValue,50,pchConfigFile);
	if (strcmp(chValue,STR_NOFIND)==0)
	{
		return FALSE;
	}
	strValue.Format("%s",chValue);
	return TRUE;	
}

//写字符串
BOOL CCfg::OnWriteCfg(LPCTSTR Section, LPCTSTR Name, char *pchText)
{
	return WritePrivateProfileString(Section, Name, pchText,pchConfigFile);
}

//读出整型
BOOL CCfg::OnReadCfg(LPCTSTR Section, LPCTSTR Name,int *pRet)
{
	*pRet=GetPrivateProfileInt(Section,Name,-1000,pchConfigFile);
	if (*pRet==-1000)
	{
		return FALSE;
	}
	return TRUE;
}

//写整型数据
BOOL CCfg::OnWriteCfg(LPCTSTR Section, LPCTSTR Name, int iNum)
{
	CString strNum;
	strNum.Format("%d",iNum);
	return WritePrivateProfileString(Section, Name, strNum.GetBuffer(0),pchConfigFile);
}

⌨️ 快捷键说明

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