FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
API-Examples/windows/APIExample/APIExample/CConfig.cpp at master · JonnyWorld/API-Examples · GitHub
JonnyWorld
/
API-Examples
Public
forked from
AgoraIO/API-Examples
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
API-Examples
/
windows
/
APIExample
/
APIExample
/
CConfig.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
85 lines (68 loc) · 2.55 KB
Breadcrumbs
API-Examples
/
windows
/
APIExample
/
APIExample
/
CConfig.cpp
Copy path
File metadata and controls
85 lines (68 loc) · 2.55 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#
include
"
stdafx.h
"
#
include
"
CConfig.h
"
CConfig*
CConfig::GetInstance
()
{
static
CConfig config;
return
&config;
}
CConfig::CConfig
()
{
::GetModuleFileName
(
NULL
, m_szZhConfigFile,
MAX_PATH
);
LPTSTR
lpLastSlash =
_tcsrchr
(m_szZhConfigFile,
_T
(
'
\\
'
)) +
1
;
_tcscpy_s
(lpLastSlash, (
_tcslen
(
_T
(
"
zh-cn.ini
"
))+
1
),
_T
(
"
zh-cn.ini
"
));
if
(::
GetFileAttributes
(m_szZhConfigFile) ==
INVALID_FILE_ATTRIBUTES
) {
HANDLE
hFile = ::
CreateFile
(m_szZhConfigFile,
GENERIC_WRITE
,
FILE_SHARE_READ
,
NULL
,
OPEN_ALWAYS
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
::CloseHandle
(hFile);
}
::GetModuleFileName
(
NULL
, m_szEnConfigFile,
MAX_PATH
);
LPTSTR
lpLastSlashEn =
_tcsrchr
(m_szEnConfigFile,
_T
(
'
\\
'
)) +
1
;
_tcscpy_s
(lpLastSlashEn, (
_tcslen
(
_T
(
"
en.ini
"
)) +
1
),
_T
(
"
en.ini
"
));
if
(::
GetFileAttributes
(m_szEnConfigFile) ==
INVALID_FILE_ATTRIBUTES
) {
HANDLE
hFile = ::
CreateFile
(m_szEnConfigFile,
GENERIC_WRITE
,
FILE_SHARE_READ
,
NULL
,
OPEN_ALWAYS
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
::CloseHandle
(hFile);
}
LCID
lcid =
GetUserDefaultLCID
();
//
LCID https://www.science.co.il/language/Locale-codes.php
if
(lcid ==
2052
) {
//
chinese
m_bChinese =
true
;
}
else
{
m_bChinese =
false
;
}
}
CConfig::~CConfig
()
{
}
CString
CConfig::GetStringValue
(CString key)
{
CString strValue =
_T
(
"
"
);
if
(m_bChinese)
::GetPrivateProfileString
(_T(
"
General
"
), key, _T(
"
Unknown
"
), strValue.GetBuffer(
MAX_PATH
), MAX_PATH, m_szZhConfigFile);
else
::GetPrivateProfileString
(_T(
"
General
"
), key, _T(
"
Unknown
"
), strValue.GetBuffer(
MAX_PATH
), MAX_PATH, m_szEnConfigFile);
return
strValue;
}
CString
CConfig::GetAPP_ID
()
{
CString
strAppID
(
APP_ID
);
if
(strAppID.
Compare
(
_T
(
"
<enter your agora app id>
"
)))
return
strAppID;
TCHAR
szFilePath[
MAX_PATH
];
::GetModuleFileName
(
NULL
, szFilePath,
MAX_PATH
);
LPTSTR
lpLastSlash =
_tcsrchr
(szFilePath,
_T
(
'
\\
'
));
if
(lpLastSlash ==
NULL
)
return
strAppID;
SIZE_T
nNameLen =
MAX_PATH
- (lpLastSlash - szFilePath +
1
);
_tcscpy_s
(lpLastSlash +
1
, nNameLen,
_T
(
"
AppID.ini
"
));
if
(!
PathFileExists
(szFilePath)) {
HANDLE
handle =
CreateFile
(szFilePath,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
NULL
,
CREATE_NEW
,
0
,
NULL
);
CloseHandle
(handle);
}
TCHAR
szAppid[
MAX_PATH
] = {
0
};
::GetPrivateProfileString
(_T(
"
AppID
"
), _T(
"
AppID
"
), NULL, szAppid, MAX_PATH, szFilePath);
if
(
_tcslen
(szAppid) ==
0
) {
::WritePrivateProfileString
(_T(
"
AppID
"
), _T(
"
AppID
"
), _T(
"
"
), szFilePath);
::ShellExecute
(
NULL
, _T(
"
open
"
), szFilePath, NULL, NULL, SW_MAXIMIZE);
}
strAppID = szAppid;
return
strAppID;
}
Back
|
FazBrowse Home
|
New Git URL