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

📄 config.cpp

📁 cngp的api短信开发包
💻 CPP
字号:
/**
*	config.cpp
*	
*	CNGP2 API Demo Application.
*
*	Copyright 2003-2006	北京风起水流软件工作室
*	
*	http://www.zealware.com
*	
*	princetoad@gmail.com
*
*/

#include "stdafx.h"
#include "config.h"

SMGAppConfig::SMGAppConfig()
{
	m_iniPath = getAppPath();
}

SMGAppConfig::~SMGAppConfig()
{
}

int SMGAppConfig::getConfigKey(CString section, CString configKey, int defaultValue)
{
	char tempChar[MAX_PATH] = "";
	GetPrivateProfileString(section, configKey, "", tempChar, MAX_PATH, m_iniPath);
	defaultValue = atoi(tempChar);
	return defaultValue;
}

CString SMGAppConfig::getConfigKey(CString section, CString configKey, CString defaultValue)
{
	char tempChar[MAX_PATH] = "";
	GetPrivateProfileString(section, configKey, "", tempChar, MAX_PATH, m_iniPath);
	defaultValue = CString(tempChar);
	return defaultValue;
}

CString SMGAppConfig::getAppPath()
{
	char pt[MAX_PATH] = "";
	CString appname = "CNGP2APIDemo_Simple";
	GetFullPathName(appname + ".exe", MAX_PATH, pt, NULL);
	CString pathtp(pt);
	pathtp.TrimLeft();
	pathtp.TrimRight();
	int pos = pathtp.ReverseFind('\\');
	pathtp = pathtp.Mid(0, pos);

	CString inipath = "";
	inipath += pathtp;
	inipath += "\\" + appname + ".ini";

	return inipath;
}

BOOL SMGAppConfig::setConfigKey(CString section, CString configKey, CString value)
{
	return WritePrivateProfileString(section, configKey, value, m_iniPath);
}

BOOL SMGAppConfig::setConfigKey(CString section, CString configKey, int value)
{
	CString strValue = _T("");
	strValue.Format("%d", value);

	return WritePrivateProfileString(section, configKey, strValue, m_iniPath);
}

⌨️ 快捷键说明

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