MCPcopy Create free account
hub / github.com/AgoraIO/API-Examples / GetAPP_ID

Method GetAPP_ID

windows/APIExample/APIExample/CConfig.cpp:58–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56
57
58CString CConfig::GetAPP_ID()
59{
60 CString strAppID(APP_ID);
61 if (strAppID.Compare(_T("<enter your agora app id>")))
62 return strAppID;
63 TCHAR szFilePath[MAX_PATH];
64 ::GetModuleFileName(NULL, szFilePath, MAX_PATH);
65 LPTSTR lpLastSlash = _tcsrchr(szFilePath, _T('\\'));
66
67 if (lpLastSlash == NULL)
68 return strAppID;
69
70 SIZE_T nNameLen = MAX_PATH - (lpLastSlash - szFilePath + 1);
71 _tcscpy_s(lpLastSlash + 1, nNameLen, _T("AppID.ini"));
72
73 if (!PathFileExists(szFilePath)) {
74 HANDLE handle = CreateFile(szFilePath, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL);
75 CloseHandle(handle);
76 }
77
78 TCHAR szAppid[MAX_PATH] = { 0 };
79 ::GetPrivateProfileString(_T("AppID"), _T("AppID"), NULL, szAppid, MAX_PATH, szFilePath);
80 if (_tcslen(szAppid) == 0) {
81 ::WritePrivateProfileString(_T("AppID"), _T("AppID"), _T(""), szFilePath);
82 ::ShellExecute(NULL, _T("open"), szFilePath, NULL, NULL, SW_MAXIMIZE);
83 }
84
85 strAppID = szAppid;
86
87 return strAppID;
88}

Callers

nothing calls this directly

Calls 1

CompareMethod · 0.80

Tested by

no test coverage detected