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

📄 hsettings.cpp

📁 Voice on phone using TAPI
💻 CPP
字号:
// HSettings.cpp: implementation of the CHSettings class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "HSettings.h"

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

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

CHSettings::CHSettings()
{
	m_deviceId = 0;
	m_ringCount = 0;
}

CHSettings::~CHSettings()
{

}

void CHSettings::Save()
{
	if (!File.Open(_T("Settings.ini"), CFile::modeWrite | CFile::modeCreate| 
		CFile::modeNoTruncate | CFile::typeText, 0)) {

        ex.ReportError();
        return ;//FALSE;
    } ;
	
	TRY {
		CString str;
		str.Format(_T("m_deviceId=%d\n"),m_deviceId);
		File.WriteString(str);

		str.Format(_T("m_ringCount=%d\n"),m_ringCount);
		File.WriteString(str);
		File.Close();

	} CATCH (CFileException, e) {
        AfxMessageBox(_T("There's a file problem."));
    } END_CATCH
}

void CHSettings::Load()
{

	if (!File.Open(_T("Settings.ini"), CFile::modeRead | 
		CFile::modeNoTruncate | CFile::typeText, 0)) {

//		ex.ReportError();

		// Unable to open the file!
		// Load default settings (In TAPI.Cpp)! 
		m_deviceId = -1;
		m_ringCount = 2;
		return;
	}
	
	TRY {
		m_deviceId = GetNextValue();
		m_ringCount = GetNextValue();
		File.Close();
	} CATCH (CFileException, e) {
		// If file doe's not exsists
		if (e->m_cause==CFileException::fileNotFound) {
			// Load default settings (In TAPI.Cpp)! 
			m_deviceId = -1;
			m_ringCount = 2;
		}
		else AfxMessageBox(_T("Unable to save error."));
    } END_CATCH

}

int CHSettings::GetValue(CString str)
{
	// UNDONE: All Impelementation!!
	return -1;
}

int CHSettings::GetNextValue()
{
	CString str = _T("");
	int nmbr = 0;

	File.ReadString(str);
	int res = str.Find(_T("="),0);
	if (res!=-1) {
		str.Delete(0,res+1);
		nmbr = _wtoi(str);
	}
	return nmbr;
}

⌨️ 快捷键说明

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