1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- // 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;
- GetPrivateProfileString(_T("Set"), _T("Repeat"), _T(""), szData, sizeof(szData), strIni);
- m_strRepeat = szData;
- GetPrivateProfileString(_T("Set"), _T("Token"), _T(""), szData, sizeof(szData), strIni);
- m_strToken = szData;
- GetPrivateProfileString(_T("Set"), _T("CsvPath"), _T(""), szData, sizeof(szData), strIni);
- m_strCsvPath = szData;
- GetPrivateProfileString(_T("Set"), _T("CsvFileDir"), _T(""), szData, sizeof(szData), strIni);
- m_strCsvFileDir = 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);
- WritePrivateProfileString(_T("Set"), _T("Repeat"), m_strRepeat, strIni);
- WritePrivateProfileString(_T("Set"), _T("CsvPath"), m_strCsvPath, strIni);
- WritePrivateProfileString(_T("Set"), _T("CsvFileDir"), m_strCsvFileDir, 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;
- }
|