国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

文章標(biāo)題

2019-11-08 20:03:58
字體:
供稿:網(wǎng)友

PRofile.h // TextFile.h: interface for the CTextFile class. // //////////////////////////////////////////////////////////////////////

if !defined(AFX_TEXTFILE_H__0B34BBD2_9145_4797_9DD1_BF7A9B8B2151__INCLUDED_)

define AFX_TEXTFILE_H__0B34BBD2_9145_4797_9DD1_BF7A9B8B2151__INCLUDED_

if _MSC_VER > 1000

pragma once

endif // _MSC_VER > 1000

include “IniFile.h”

class CGlobalInterface { protected: static CString m_strSdScanDirectory; static CString m_strLanguage;

public: static void SetSdScanDirectory(CString szDirectory); static CString GetSdScanDirectory(); static void SetLanguage(CString szLanguage); static CString GetLanguage();

public: static CString m_strEcuId;

/** */static TCHAR * PF_GetWordStr(const char *cStr);/** CString to string*/static char * PF_GetCharStr(const TCHAR *wStr);

};

class CProfile { public: static CString GetString(CString sFile,CString sSect,CString sKey ,CString sDftValue,BOOL bCaseSensitive=TRUE); static INT GetInteger(CString sFile,CString sSect,CString sKey ,INT nDftValue,BOOL bCaseSensitive=TRUE); static BOOL WriteString(CString sFile,CString sSect,CString sKey ,CString sValue,BOOL bCaseSensitive=TRUE); static BOOL WriteInteger(CString sFile,CString sSect,CString sKey ,INT nValue,BOOL bCaseSensitive=TRUE);

private: static CIniFile m_iniF; static CString m_sLastFile; };

endif // !defined(AFX_TEXTFILE_H__0B34BBD2_9145_4797_9DD1_BF7A9B8B2151__INCLUDED_)

Profile.cpp

include “stdafx.h”

include “Profile.h”

ifdef _DEBUG

undef THIS_FILE

static char THIS_FILE[]=FILE;

define new DEBUG_NEW

endif

CString CGlobalInterface::m_strSdScanDirectory; CString CGlobalInterface::m_strLanguage;

define PLATFORM_MAX_BUFFER 4096

TCHAR g_WordBuf[PLATFORM_MAX_BUFFER]; char g_CharBuf[PLATFORM_MAX_BUFFER];

TCHAR * CGlobalInterface::PF_GetWordStr(const char *cStr) { int wlen;

wlen=MultiByteToWideChar(CP_ACP,0,cStr,strlen(cStr), (LPWSTR)g_WordBuf,PLATFORM_MAX_BUFFER);g_WordBuf[wlen]=_T('/0');return g_WordBuf;

}

char * CGlobalInterface::PF_GetCharStr(const TCHAR *wStr) { int len;

len=WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)wStr, wcslen((const wchar_t *)wStr), g_CharBuf, PLATFORM_MAX_BUFFER, NULL, NULL);g_CharBuf[len]='/0';return g_CharBuf;

}

/*—————————————————————————– 功 能:設(shè)置顯示程序工作目錄 參數(shù)說明:CString pDirectory-指向工作目錄的指針 返 回 值:無 說 明:無 —————————————————————————–*/ void CGlobalInterface::SetSdScanDirectory(CString pDirectory) { m_strSdScanDirectory = pDirectory; }

/*—————————————————————————– 功 能:取得顯示程序工作目錄 參數(shù)說明:無 返 回 值:工作目錄絕對路徑名 說 明:無 —————————————————————————–*/ CString CGlobalInterface::GetSdScanDirectory() { return m_strSdScanDirectory; }

/*—————————————————————————– 功 能:設(shè)置語言代碼 參數(shù)說明:CString pLanguage-指向設(shè)置語言代碼字符串的指針 返 回 值:無 說 明:無 —————————————————————————–*/ void CGlobalInterface::SetLanguage(CString pLanguage) { m_strLanguage = pLanguage; }

/*—————————————————————————– 功 能:取得語言代碼 參數(shù)說明:無 返 回 值:語言代碼字符串 說 明:無 —————————————————————————–*/ CString CGlobalInterface::GetLanguage() { return m_strLanguage; }

/static /CIniFile CProfile::m_iniF; /static /CString CProfile::m_sLastFile(SZ_EMPTY);

/*—————————————————————————– 功 能:讀取配置串 參數(shù)說明:CString sFile 配置文件名, CString sSect 段名, CString sKey 鍵值, CString sDftValue 缺省串 返 回 值:讀入的字符串 說 明:無 —————————————————————————–*/ /static / CString CProfile::GetString(CString sFile,CString sSect,CString sKey ,CString sDftValue,BOOL bCaseSensitive/=TRUE/) { // sanity check if(sFile.IsEmpty()||sSect.IsEmpty()||sKey.IsEmpty()) { return sDftValue; }

if(sFile.CompareNoCase(m_sLastFile)!=0){ if(m_iniF.ReadFile(CGlobalInterface::PF_GetCharStr(sFile),bCaseSensitive)) { m_sLastFile = sFile; } else { return sDftValue; }}string s_sect = CGlobalInterface::PF_GetCharStr(sSect);string s_key = CGlobalInterface::PF_GetCharStr(sKey);string s_dft_v = CGlobalInterface::PF_GetCharStr(sDftValue);LPCSTR lpStrRet = m_iniF.GetValue(s_sect.c_str(),s_key.c_str(),s_dft_v.c_str(),bCaseSensitive);return (CString)lpStrRet;

}

/*—————————————————————————– 功 能:讀取配置數(shù) 參數(shù)說明:CString sFile 配置文件名, CString sSect 段名, CString sKey 鍵值, INT iDefaultValue 缺省值 返 回 值:讀入的數(shù)值 說 明:無 —————————————————————————–*/ /static / INT CProfile::GetInteger(CString sFile,CString sSect,CString sKey,INT nDftValue ,BOOL bCaseSensitive/=TRUE/) { CString s_dft_value; s_dft_value.Format(_T(“%d”),nDftValue);

CString s_value = GetString(sFile,sSect,sKey,s_dft_value,bCaseSensitive);return atoi(CGlobalInterface::PF_GetCharStr(s_value));

}

/*—————————————————————————– 功 能:寫入配置串 參數(shù)說明:CString sFile 配置文件名, CString sSect 段名, CString sKey 鍵值, CString sValue 寫入串 返 回 值:成功–TRUE 失敗–FALSE 說 明:無 —————————————————————————–*/ /static / BOOL CProfile::WriteString(CString sFile,CString sSect,CString sKey ,CString sValue,BOOL bCaseSensitive/=TRUE/) { // sanity check if(sFile.IsEmpty()) return FALSE; if(sSect.IsEmpty()) return FALSE; if(sKey.IsEmpty()) return FALSE;

if(m_iniF.ReadFile(CGlobalInterface::PF_GetCharStr(sFile),bCaseSensitive)){ m_sLastFile = sFile;}else{ return FALSE;}// always create new if section/key's not existedstring s_sect = CGlobalInterface::PF_GetCharStr(sSect);string s_key = CGlobalInterface::PF_GetCharStr(sKey);string s_v = CGlobalInterface::PF_GetCharStr(sValue);BOOL bRet = m_iniF.SetValue(s_sect.c_str(),s_key.c_str(),s_v.c_str(),TRUE,bCaseSensitive);if (!bRet){ return bRet;}// have to write to file every timebRet = m_iniF.WriteFile(CGlobalInterface::PF_GetCharStr(m_sLastFile));if (!bRet){ return bRet;} return TRUE;

}

/*—————————————————————————– 功 能:寫入配置數(shù) 參數(shù)說明:CString sFile 配置文件名, CString sSect 段名, CString sKey 鍵值, INT nValue 寫入值 返 回 值:成功–TRUE 失敗–FALSE 說 明:無 —————————————————————————–*/ /static / BOOL CProfile::WriteInteger(CString sFile,CString sSect,CString sKey,INT nValue ,BOOL bCaseSensitive/=TRUE/) { CString s_value; s_value.Format(_T(“%d”),nValue);

return WriteString(sFile,sSect,sKey,s_value,bCaseSensitive);

}


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 和静县| 云浮市| 肇州县| 巴中市| 雷山县| 神农架林区| 宣汉县| 琼海市| 金阳县| 探索| 昌都县| 卢氏县| 台南县| 确山县| 北宁市| 五常市| 磐安县| 南昌市| 中阳县| 库尔勒市| 定州市| 万荣县| 习水县| 兴和县| 罗甸县| 宁陕县| 南木林县| 商河县| 台山市| 西贡区| 阿尔山市| 阿城市| 额济纳旗| 济阳县| 金塔县| 天柱县| 六盘水市| 阜新市| 辽中县| 阜新市| 铜山县|