@@ -8,21 +8,27 @@ CConfig* CConfig::GetInstance()
88
99CConfig::CConfig ()
1010{
11- ::GetModuleFileName (NULL , m_szZhConfigFile, MAX_PATH);
12- LPTSTR lpLastSlash = _tcsrchr (m_szZhConfigFile, _T (' \\ ' )) + 1 ;
13- _tcscpy_s (lpLastSlash, MAX_PATH, _T (" zh-cn.ini" ));
14-
15- if (::GetFileAttributes (m_szZhConfigFile) == INVALID_FILE_ATTRIBUTES) {
16- HANDLE hFile = ::CreateFile (m_szZhConfigFile, GENERIC_WRITE, FILE_SHARE_READ, NULL , OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
11+ TCHAR szZhConfigFile[MAX_PATH] = { 0 };
12+ TCHAR szEnConfigFile[MAX_PATH] = { 0 };
13+ ::GetModuleFileName (NULL , szZhConfigFile, MAX_PATH);
14+ LPTSTR lpLastSlash = _tcsrchr (szZhConfigFile, _T (' \\ ' )) + 1 ;
15+ *lpLastSlash = 0 ;
16+ m_strZhConfigFile = szZhConfigFile;
17+ m_strZhConfigFile += _T (" zh-cn.ini" );
18+
19+ if (::GetFileAttributes (m_strZhConfigFile) == INVALID_FILE_ATTRIBUTES) {
20+ HANDLE hFile = ::CreateFile (m_strZhConfigFile, GENERIC_WRITE, FILE_SHARE_READ, NULL , OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
1721 ::CloseHandle (hFile);
1822 }
1923
20- ::GetModuleFileName (NULL , m_szEnConfigFile, MAX_PATH);
21- LPTSTR lpLastSlashEn = _tcsrchr (m_szEnConfigFile, _T (' \\ ' )) + 1 ;
22- _tcscpy_s (lpLastSlashEn, MAX_PATH, _T (" en.ini" ));
24+ ::GetModuleFileName (NULL , szEnConfigFile, MAX_PATH);
25+ LPTSTR lpLastSlashEn = _tcsrchr (szEnConfigFile, _T (' \\ ' )) + 1 ;
26+ *lpLastSlashEn = 0 ;
27+ m_strEnConfigFile = szEnConfigFile;
28+ m_strEnConfigFile += _T (" en.ini" );
2329
24- if (::GetFileAttributes (m_szEnConfigFile ) == INVALID_FILE_ATTRIBUTES) {
25- HANDLE hFile = ::CreateFile (m_szEnConfigFile , GENERIC_WRITE, FILE_SHARE_READ, NULL , OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
30+ if (::GetFileAttributes (m_strEnConfigFile ) == INVALID_FILE_ATTRIBUTES) {
31+ HANDLE hFile = ::CreateFile (m_strEnConfigFile , GENERIC_WRITE, FILE_SHARE_READ, NULL , OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
2632 ::CloseHandle (hFile);
2733 }
2834 LCID lcid = GetUserDefaultLCID ();// LCID https://www.science.co.il/language/Locale-codes.php
@@ -42,9 +48,9 @@ CString CConfig::GetStringValue(CString key)
4248{
4349 CString strValue = _T (" " );
4450 if (m_bChinese)
45- ::GetPrivateProfileString (_T(" General" ), key, _T(" Unknown" ), strValue.GetBuffer(MAX_PATH), MAX_PATH, m_szZhConfigFile );
51+ ::GetPrivateProfileString (_T(" General" ), key, _T(" Unknown" ), strValue.GetBuffer(MAX_PATH), MAX_PATH, m_strZhConfigFile );
4652 else
47- ::GetPrivateProfileString (_T(" General" ), key, _T(" Unknown" ), strValue.GetBuffer(MAX_PATH), MAX_PATH, m_szEnConfigFile );
53+ ::GetPrivateProfileString (_T(" General" ), key, _T(" Unknown" ), strValue.GetBuffer(MAX_PATH), MAX_PATH, m_strEnConfigFile );
4854 return strValue;
4955}
5056
0 commit comments