Index: src/ch/AppHelper.cpp =================================================================== diff -u -N -rd9527df01ee91b35d9a5fdccb80ded25a9c8265f -r58de8d7360813537b384eff808c031f9e63db4de --- src/ch/AppHelper.cpp (.../AppHelper.cpp) (revision d9527df01ee91b35d9a5fdccb80ded25a9c8265f) +++ src/ch/AppHelper.cpp (.../AppHelper.cpp) (revision 58de8d7360813537b384eff808c031f9e63db4de) @@ -112,6 +112,14 @@ return m_pathProcessor.GetProgramPath(); } +CString CAppHelper::GetFullProgramPath() const +{ + CString strKey; + strKey.Format(_T("%s\\%s"), (PCTSTR)m_pathProcessor.GetProgramPath(), m_pszProgramName); + + return strKey; +} + bool CAppHelper::IsInPortableMode() { if(!m_optPortableMode.is_initialized()) @@ -126,66 +134,3 @@ return m_optPortableMode.get(); } - -bool CAppHelper::SetAutorun(bool bEnable) -{ - // check the current key value (to avoid irritating messages from some firewall software) - HKEY hkeyRun = nullptr; - CString strValue; - CString strKey; - DWORD dwType = REG_SZ; - DWORD dwCount = _MAX_PATH * sizeof(TCHAR); - - LSTATUS lStatus = RegOpenKeyEx(HKEY_CURRENT_USER, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"), 0, KEY_QUERY_VALUE, &hkeyRun); - if(lStatus != ERROR_SUCCESS) - return false; - - lStatus = RegQueryValueEx(hkeyRun, m_pszAppName, nullptr, &dwType, (BYTE*)strValue.GetBufferSetLength(_MAX_PATH), &dwCount); - RegCloseKey(hkeyRun); - - if(lStatus != ERROR_SUCCESS && lStatus != ERROR_FILE_NOT_FOUND) - { - strValue.ReleaseBuffer(0); - return false; - } - if(lStatus == ERROR_FILE_NOT_FOUND) - { - strValue.ReleaseBuffer(0); - - // if there is no key in registry and we don't want it, then return with ok status - if(!bEnable) - return true; - - // format the data to be written to registry - strKey.Format(_T("%s\\%s"), (PCTSTR)m_pathProcessor.GetProgramPath(), m_pszProgramName); - } - else - { - // key found - strValue.ReleaseBuffer(dwCount / sizeof(TCHAR)); - - if(bEnable) - { - // key exists in registry, check if the value is correct - strKey.Format(_T("%s\\%s"), (PCTSTR)m_pathProcessor.GetProgramPath(), m_pszProgramName); - - if(strValue.CompareNoCase(strKey) == 0) - return true; - } - } - - // we want to write information to the registry - // storing key in registry - lStatus = RegOpenKeyEx(HKEY_CURRENT_USER, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"), 0, KEY_ALL_ACCESS, &hkeyRun); - if(lStatus != ERROR_SUCCESS) - return false; - - if(bEnable) - lStatus = RegSetValueEx(hkeyRun, m_pszAppName, 0, REG_SZ, (BYTE*)(PCTSTR)strKey, (DWORD)(strKey.GetLength() + 1) * sizeof(TCHAR)); - else - lStatus = RegDeleteValue(hkeyRun, m_pszAppName); - - RegCloseKey(hkeyRun); - - return lStatus == ERROR_SUCCESS; -}