- regApp += _T("\\") + szApplicationName;\r
- // on/off\r
- if (bSaveAndValidate) { // retrieve\r
- for (int nCommandID = 1; nCommandID < MAX_COMMAND; ++nCommandID) {\r
- szEntry = CCommands::GetCommandName(nCommandID);\r
- if (szEntry.IsEmpty()) {\r
- break;\r
- }\r
- HKEY hKey = NULL;\r
- CString regKey = regApp + _T("\\") + szEntry;\r
- if (RegOpenKeyEx(HKEY_CURRENT_USER, regKey, 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;\r
- RegEnumKeyEx(hKey, dwIndex, szKeyBind, &dwKeyBind, NULL, NULL, NULL, &ft) == ERROR_SUCCESS;\r
- ++dwIndex) {\r
- int nCommandType = 0;\r
- int nKey = 0;\r
- ReadKeyBind(&nCommandType, &nKey, szKeyBind);\r
- m_Data[nApplicationID].SetCommandID(nCommandType, nKey, nCommandID);\r
- memset(szKeyBind, 0, sizeof(szKeyBind));\r
- dwKeyBind = sizeof(szKeyBind);\r
- }\r
- RegCloseKey(hKey);\r
- } else {\r
- // Use default setting\r
- for (int i = 0; ; ++i) {\r
- if (CCommands::GetDefaultControlID(nCommandID, i) == IDC_CO2) {\r
- continue;\r
- }\r
-\r
- int nCommandType = CCommands::GetDefaultCommandType(nCommandID, i);\r
- int nKey = CCommands::GetDefaultCommandKey(nCommandID, i);\r
- if (nKey == 0) {\r
- break;\r
- }\r
- m_Data[nApplicationID].SetCommandID(nCommandType, nKey, nCommandID);\r
- }\r
- }\r
- }\r
- for (int nFunctionID = 0; nFunctionID < CDotXkeymacs::GetFunctionNumber(); ++nFunctionID) {\r
- HKEY hKey = NULL;\r
- CString regKey = regApp + _T("\\") + CDotXkeymacs::GetFunctionSymbol(nFunctionID);\r
- if (RegOpenKeyEx(HKEY_CURRENT_USER, regKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS) {\r
- // Use registry data\r
- CDotXkeymacs::ClearKey(nFunctionID, nApplicationID);\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 nCommandType = 0;\r
- int nKey = 0;\r
- ReadKeyBind(&nCommandType, &nKey, szKeyBind);\r
- CDotXkeymacs::SetKey(nFunctionID, nApplicationID, nCommandType, nKey);\r
-\r
- memset(szKeyBind, 0, sizeof(szKeyBind));\r
- dwKeyBind = sizeof(szKeyBind);\r
- }\r
- RegCloseKey(hKey);\r
- }\r
- }\r
- } else { // initialize\r
- // create all commands\r
- for (int nCommandID = 1; nCommandID < MAX_COMMAND; ++nCommandID) {\r
- szEntry = CCommands::GetCommandName(nCommandID);\r
- if (szEntry.IsEmpty()) {\r
- break;\r
- }\r
-\r
- SaveCommand(szApplicationName, nCommandID);\r
- }\r
- for (int nCommandType = 0; nCommandType < MAX_COMMAND_TYPE; ++nCommandType) {\r
- for (int nKey = 0; nKey < MAX_KEY; ++nKey) {\r
- int nCommandID = m_Data[nApplicationID].GetCommandID(nCommandType, nKey);\r
- SaveKeyBind(szApplicationName, nCommandID, nCommandType, nKey);\r
+ regApp += _T("\\") + appName;\r
+ for (int nCommandID = 1; nCommandID < MAX_COMMAND; nCommandID++) {\r
+ entry = CCommands::GetCommandName(nCommandID);\r
+ HKEY hKey;\r
+ const CString& regKey = regApp + _T("\\") + entry;\r
+ if (RegOpenKeyEx(HKEY_CURRENT_USER, regKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS) {\r
+ TCHAR szKeyBind[128];\r
+ DWORD dwKeyBind = _countof(szKeyBind);\r
+ for (DWORD dwIndex = 0; RegEnumKeyEx(hKey, dwIndex, szKeyBind, &dwKeyBind, NULL, NULL, NULL, NULL) == ERROR_SUCCESS; dwIndex++) {\r
+ int nCommandType, nKey;\r
+ ReadKeyBind(&nCommandType, &nKey, szKeyBind);\r
+ m_Data[nAppID].SetCommandID(nCommandType, nKey, nCommandID);\r
+ dwKeyBind = _countof(szKeyBind);\r