\r
void CProfile::LevelUp()\r
{\r
- const int nDefalutLevel = 0;\r
- const int nLatestLevel = 4;\r
-\r
- CString szSection;\r
- CString szEntry;\r
- szEntry.Format(_T("Level"));\r
-\r
- switch (AfxGetApp()->GetProfileInt(szSection, szEntry, nDefalutLevel)) {\r
- case nDefalutLevel:\r
- {\r
- for (int nAppID = 0; nAppID < MAX_APP; ++nAppID) {\r
- CString szEntry;\r
- szEntry.Format(IDS_REG_ENTRY_APPLICATION, nAppID);\r
-\r
- CString szApplicationName;\r
- szApplicationName = AfxGetApp()->GetProfileString(CString(MAKEINTRESOURCE(IDS_REG_SECTION_APPLICATION)), szEntry);\r
- if (szApplicationName.IsEmpty()) {\r
- continue;\r
- }\r
-\r
- AddKeyBind2C_(szApplicationName, VK_LCONTROL);\r
- AddKeyBind2C_(szApplicationName, VK_RCONTROL);\r
- }\r
- }\r
- // Do NOT write break; here.\r
- case 1:\r
- {\r
- for (int nAppID = 0; nAppID < MAX_APP; ++nAppID) {\r
- CString szEntry;\r
- szEntry.Format(IDS_REG_ENTRY_APPLICATION, nAppID);\r
-\r
- CString szApplicationName;\r
- szApplicationName = AfxGetApp()->GetProfileString(CString(MAKEINTRESOURCE(IDS_REG_SECTION_APPLICATION)), szEntry);\r
- if (szApplicationName.IsEmpty()) {\r
- continue;\r
- }\r
-\r
- // Set kill-ring-max 1 if it is 0.\r
- if (!AfxGetApp()->GetProfileInt(szApplicationName, CString(MAKEINTRESOURCE(IDS_REG_ENTRY_KILL_RING_MAX)), 0)) {\r
- AfxGetApp()->WriteProfileInt(szApplicationName, CString(MAKEINTRESOURCE(IDS_REG_ENTRY_KILL_RING_MAX)), 1);\r
- }\r
- }\r
- }\r
- // Do NOT write break; here.\r
- case 2:\r
- {\r
- for (int nAppID = 0; nAppID < MAX_APP; ++nAppID) {\r
- CString szEntry;\r
- szEntry.Format(IDS_REG_ENTRY_APPLICATION, nAppID);\r
-\r
- CString szApplicationName;\r
- szApplicationName = AfxGetApp()->GetProfileString(CString(MAKEINTRESOURCE(IDS_REG_SECTION_APPLICATION)), szEntry);\r
- if (szApplicationName.IsEmpty()) {\r
- continue;\r
- }\r
-\r
+ const int nCurrentLevel = AfxGetApp()->GetProfileInt(_T(""), _T("Level"), 0);\r
+ for (int nAppID = 0; nAppID < MAX_APP; ++nAppID) {\r
+ CString entry;\r
+ entry.Format(IDS_REG_ENTRY_APPLICATION, nAppID);\r
+ const CString appName = AfxGetApp()->GetProfileString(CString(MAKEINTRESOURCE(IDS_REG_SECTION_APPLICATION)), entry);\r
+ if (appName.IsEmpty())\r
+ continue;\r
+ switch (nCurrentLevel) {\r
+ case 0:\r
+ AddKeyBind2C_(appName, VK_LCONTROL);\r
+ AddKeyBind2C_(appName, VK_RCONTROL);\r
+ // fall through\r
+ case 1:\r
+ // Set kill-ring-max 1 if it is 0.\r
+ if (!AfxGetApp()->GetProfileInt(appName, CString(MAKEINTRESOURCE(IDS_REG_ENTRY_KILL_RING_MAX)), 0))\r
+ AfxGetApp()->WriteProfileInt(appName, CString(MAKEINTRESOURCE(IDS_REG_ENTRY_KILL_RING_MAX)), 1);\r
+ // fall through\r
+ case 2:\r
+ {\r
// Chaged a label from Enter to newline.\r
- CString szSrcSubKey(MAKEINTRESOURCE(IDS_REGSUBKEY_DATA));\r
- szSrcSubKey += _T("\\") + szApplicationName + _T("\\") + _T("Enter");\r
- CString szDestSubKey(MAKEINTRESOURCE(IDS_REGSUBKEY_DATA));\r
- szDestSubKey += _T("\\") + szApplicationName + _T("\\") + _T("newline");\r
- HKEY hKeyDest = NULL;\r
- if (RegCreateKeyEx(HKEY_CURRENT_USER, szDestSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKeyDest, NULL) == ERROR_SUCCESS) {\r
- SHCopyKey(HKEY_CURRENT_USER, szSrcSubKey, hKeyDest, NULL);\r
- SHDeleteKey(HKEY_CURRENT_USER, szSrcSubKey);\r
- RegCloseKey(hKeyDest);\r
+ const CString subKey = CString(MAKEINTRESOURCE(IDS_REGSUBKEY_DATA)) + _T("\\") + appName;\r
+ const CString srcKey = subKey + _T("\\") + _T("Enter");\r
+ const CString dstKey = subKey + _T("\\") + _T("newline");\r
+ HKEY hDstKey = NULL;\r
+ if (RegCreateKeyEx(HKEY_CURRENT_USER, dstKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hDstKey, NULL) == ERROR_SUCCESS) {\r
+ SHCopyKey(HKEY_CURRENT_USER, srcKey, hDstKey, NULL);\r
+ SHDeleteKey(HKEY_CURRENT_USER, srcKey);\r
+ RegCloseKey(hDstKey);\r
}\r
}\r
- }\r
- // Do NOT write break; here.\r
- case 3:\r
- {\r
- for (int nAppID = 0; nAppID < MAX_APP; ++nAppID) {\r
- CString szEntry;\r
- szEntry.Format(IDS_REG_ENTRY_APPLICATION, nAppID);\r
-\r
- CString szApplicationName;\r
- szApplicationName = AfxGetApp()->GetProfileString(CString(MAKEINTRESOURCE(IDS_REG_SECTION_APPLICATION)), szEntry);\r
- if (szApplicationName.IsEmpty()) {\r
- continue;\r
- }\r
-\r
- // rename original function to remove IDS_REG_ORIGINAL_PREFIX\r
- for (int nFuncID = 0; nFuncID < CDotXkeymacs::GetFunctionNumber(); ++nFuncID) {\r
- HKEY hKey = NULL;\r
- CString szSubKey(MAKEINTRESOURCE(IDS_REGSUBKEY_DATA));\r
- szSubKey += _T("\\") + szApplicationName + _T("\\") + CString(MAKEINTRESOURCE(IDS_REG_ORIGINAL_PREFIX)) + CDotXkeymacs::GetFunctionSymbol(nFuncID);\r
- if (RegOpenKeyEx(HKEY_CURRENT_USER, szSubKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS) {\r
- // Use registry data\r
- TCHAR szKeyBind[128] = {'\0'};\r
- DWORD dwKeyBind = sizeof(szKeyBind);\r
- FILETIME ft = {'\0'}; // not use\r
- for (DWORD dwIndex = 0; RegEnumKeyEx(hKey, dwIndex, szKeyBind, &dwKeyBind, NULL, NULL, NULL, &ft) == ERROR_SUCCESS; ++dwIndex) {\r
- int nType, nKey;\r
- ReadKeyBind(nType, nKey, szKeyBind);\r
- SaveKeyBind(szApplicationName, CDotXkeymacs::GetFunctionSymbol(nFuncID), nType, nKey);\r
-\r
- memset(szKeyBind, 0, sizeof(szKeyBind));\r
- dwKeyBind = sizeof(szKeyBind);\r
- }\r
- RegCloseKey(hKey);\r
+ // fall through\r
+ case 3:\r
+ // rename original function to remove IDS_REG_ORIGINAL_PREFIX\r
+ for (int nFuncID = 0; nFuncID < CDotXkeymacs::GetFunctionNumber(); ++nFuncID) {\r
+ HKEY hKey = NULL;\r
+ const CString subKey = CString(MAKEINTRESOURCE(IDS_REGSUBKEY_DATA)) + _T("\\") + appName + _T("\\") + CString(MAKEINTRESOURCE(IDS_REG_ORIGINAL_PREFIX)) + CDotXkeymacs::GetFunctionSymbol(nFuncID);\r
+ if (RegOpenKeyEx(HKEY_CURRENT_USER, subKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS) {\r
+ // Use registry data\r
+ TCHAR szKeyBind[128];\r
+ DWORD dwKeyBind = sizeof(szKeyBind);\r
+ for (DWORD dwIndex = 0; RegEnumKeyEx(hKey, dwIndex, szKeyBind, &dwKeyBind, NULL, NULL, NULL, NULL) == ERROR_SUCCESS; ++dwIndex) {\r
+ int nType, nKey;\r
+ ReadKeyBind(nType, nKey, szKeyBind);\r
+ SaveKeyBind(appName, CDotXkeymacs::GetFunctionSymbol(nFuncID), nType, nKey);\r
+ dwKeyBind = sizeof(szKeyBind);\r
}\r
+ RegCloseKey(hKey);\r
}\r
}\r
}\r
-// case 4:\r
-// foo();\r
-// ...\r
-// case nLatestLevel-1:\r
-// bar();\r
- AfxGetApp()->WriteProfileInt(szSection, szEntry, nLatestLevel);\r
- break;\r
- default:\r
- break;\r
}\r
+ AfxGetApp()->WriteProfileInt(_T(""), _T("Level"), 4);\r
}\r
\r
void CProfile::InitDllData()\r