123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- // Config.cpp: implementation of the CConfig class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "pch.h"
- #include <atlbase.h>
- #include "Config.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- CConfig CConfig::s_Config;
- CConfig::CConfig()
- {
-
- }
- BOOL CConfig::SaveSetting()
- {
- BOOL bRet=FALSE;
- bRet=SaveToINI();
- return bRet;
- }
- BOOL CConfig::LoadFromINI()
- {
- TCHAR szData[_MAX_PATH];
- memset(szData, 0, sizeof(szData));
- CString strIni = GetAppPath() + _T("config.ini");
-
- GetPrivateProfileString(_T("Set"), _T("Txt"), _T(""), szData, sizeof(szData), strIni);
- m_strTxt = szData;
- GetPrivateProfileString(_T("Set"), _T("Pdf"), _T(""), szData, sizeof(szData), strIni);
- m_strPdf = szData;
- GetPrivateProfileString(_T("Set"), _T("Mode"), _T(""), szData, sizeof(szData), strIni);
- m_strMode = szData;
- GetPrivateProfileString(_T("Set"), _T("Img"), _T(""), szData, sizeof(szData), strIni);
- m_strImg = szData;
- GetPrivateProfileString(_T("Set"), _T("Cut"), _T(""), szData, sizeof(szData), strIni);
- m_strCut = szData;
- return TRUE;
- }
- BOOL CConfig::SaveToINI()
- {
- TCHAR sTmp[64] = {0};
- std::string strPwd;
- CString strTmp = _T("");
- CString strIni = GetAppPath() + _T("config.ini");
-
- WritePrivateProfileString(_T("Set"), _T("Txt"), m_strTxt, strIni);
- WritePrivateProfileString(_T("Set"), _T("Pdf"), m_strPdf, strIni);
- WritePrivateProfileString(_T("Set"), _T("Mode"), m_strMode, strIni);
- WritePrivateProfileString(_T("Set"), _T("Img"), m_strImg, strIni);
- WritePrivateProfileString(_T("Set"), _T("Cut"), m_strCut, strIni);
- return TRUE;
- }
- CString CConfig::GetAppPath()
- {
- CString strAppPath;
- TCHAR *pBuf=strAppPath.GetBuffer(_MAX_PATH);
- GetModuleFileName(AfxGetApp()->m_hInstance,pBuf,_MAX_PATH);
- TCHAR* pch=_tcsrchr(pBuf,_T('\\'));
- if(pch)
- *(pch+1)=0;
- else
- _tcscat(pBuf,_T("\\"));
- strAppPath.ReleaseBuffer();
- return strAppPath;
- }
|