diff options
author | Hendrik Leppkes <h.leppkes@gmail.com> | 2012-12-14 21:14:05 +0400 |
---|---|---|
committer | Hendrik Leppkes <h.leppkes@gmail.com> | 2012-12-14 21:15:07 +0400 |
commit | f2a0758e231c9650018d2cfc353acafb67a9c1a0 (patch) | |
tree | 2153d63ab30f97502af81a6bccb6238ef65216f0 | |
parent | 3e0f4f10182d22f839b23d8e1aa936d5b2f407ba (diff) |
Open Registry keys read-only when loading settings.
Idea from a patch by clsid.
-rw-r--r-- | common/DSUtilLite/registry.cpp | 8 | ||||
-rw-r--r-- | common/DSUtilLite/registry.h | 4 | ||||
-rw-r--r-- | decoder/LAVAudio/LAVAudio.cpp | 4 | ||||
-rw-r--r-- | decoder/LAVVideo/LAVVideo.cpp | 8 | ||||
-rw-r--r-- | demuxer/LAVSplitter/LAVSplitter.cpp | 4 |
5 files changed, 14 insertions, 14 deletions
diff --git a/common/DSUtilLite/registry.cpp b/common/DSUtilLite/registry.cpp index e150ab9f..1662e34e 100644 --- a/common/DSUtilLite/registry.cpp +++ b/common/DSUtilLite/registry.cpp @@ -52,10 +52,10 @@ CRegistry::CRegistry() : m_key(NULL) { } -CRegistry::CRegistry(HKEY hkeyRoot, LPCTSTR pszSubKey, HRESULT &hr) +CRegistry::CRegistry(HKEY hkeyRoot, LPCTSTR pszSubKey, HRESULT &hr, BOOL bReadOnly) : m_key(NULL) { - hr = Open(hkeyRoot, pszSubKey); + hr = Open(hkeyRoot, pszSubKey, bReadOnly); } CRegistry::~CRegistry() @@ -65,14 +65,14 @@ CRegistry::~CRegistry() delete m_key; } -HRESULT CRegistry::Open(HKEY hkeyRoot, LPCTSTR pszSubKey) +HRESULT CRegistry::Open(HKEY hkeyRoot, LPCTSTR pszSubKey, BOOL bReadOnly) { LONG lRet; if (m_key != NULL) { return E_UNEXPECTED; } m_key = new HKEY(); - lRet = RegOpenKeyEx(hkeyRoot, pszSubKey, 0, KEY_READ | KEY_WRITE, m_key); + lRet = RegOpenKeyEx(hkeyRoot, pszSubKey, 0, bReadOnly ? KEY_READ : KEY_READ|KEY_WRITE, m_key); if (lRet != ERROR_SUCCESS) { delete m_key; m_key = NULL; diff --git a/common/DSUtilLite/registry.h b/common/DSUtilLite/registry.h index 57c60a2e..ba7193d2 100644 --- a/common/DSUtilLite/registry.h +++ b/common/DSUtilLite/registry.h @@ -27,10 +27,10 @@ class CRegistry { public: CRegistry(); - CRegistry(HKEY hkeyRoot, LPCTSTR pszSubKey, HRESULT &hr); + CRegistry(HKEY hkeyRoot, LPCTSTR pszSubKey, HRESULT &hr, BOOL bReadOnly = FALSE); ~CRegistry(); - HRESULT Open(HKEY hkeyRoot, LPCTSTR pszSubKey); + HRESULT Open(HKEY hkeyRoot, LPCTSTR pszSubKey, BOOL bReadOnly = FALSE); std::wstring ReadString(LPCTSTR pszKey, HRESULT &hr); HRESULT WriteString(LPCTSTR pszKey, LPCTSTR pszValue); diff --git a/decoder/LAVAudio/LAVAudio.cpp b/decoder/LAVAudio/LAVAudio.cpp index 45e92e9e..191089aa 100644 --- a/decoder/LAVAudio/LAVAudio.cpp +++ b/decoder/LAVAudio/LAVAudio.cpp @@ -225,7 +225,7 @@ HRESULT CLAVAudio::LoadSettings() BOOL bFlag; BYTE *pBuf = NULL; - CRegistry reg = CRegistry(HKEY_CURRENT_USER, LAVC_AUDIO_REGISTRY_KEY, hr); + CRegistry reg = CRegistry(HKEY_CURRENT_USER, LAVC_AUDIO_REGISTRY_KEY, hr, TRUE); if (SUCCEEDED(hr)) { bFlag = reg.ReadDWORD(L"DRCEnabled", hr); if (SUCCEEDED(hr)) m_settings.DRCEnabled = bFlag; @@ -309,7 +309,7 @@ HRESULT CLAVAudio::LoadSettings() } } - CRegistry regF = CRegistry(HKEY_CURRENT_USER, LAVC_AUDIO_REGISTRY_KEY_FORMATS, hr); + CRegistry regF = CRegistry(HKEY_CURRENT_USER, LAVC_AUDIO_REGISTRY_KEY_FORMATS, hr, TRUE); if (SUCCEEDED(hr)) { for (int i = 0; i < Codec_AudioNB; ++i) { const codec_config_t *info = get_codec_config((LAVAudioCodec)i); diff --git a/decoder/LAVVideo/LAVVideo.cpp b/decoder/LAVVideo/LAVVideo.cpp index 814f9096..524b47cd 100644 --- a/decoder/LAVVideo/LAVVideo.cpp +++ b/decoder/LAVVideo/LAVVideo.cpp @@ -192,7 +192,7 @@ HRESULT CLAVVideo::LoadSettings() BOOL bFlag; DWORD dwVal; - CRegistry reg = CRegistry(HKEY_CURRENT_USER, LAVC_VIDEO_REGISTRY_KEY, hr); + CRegistry reg = CRegistry(HKEY_CURRENT_USER, LAVC_VIDEO_REGISTRY_KEY, hr, TRUE); if (SUCCEEDED(hr)) { dwVal = reg.ReadDWORD(L"StreamAR", hr); if (SUCCEEDED(hr)) m_settings.StreamAR = dwVal; @@ -231,7 +231,7 @@ HRESULT CLAVVideo::LoadSettings() if (SUCCEEDED(hr)) m_settings.bMSWMV9DMO = bFlag; } - CRegistry regF = CRegistry(HKEY_CURRENT_USER, LAVC_VIDEO_REGISTRY_KEY_FORMATS, hr); + CRegistry regF = CRegistry(HKEY_CURRENT_USER, LAVC_VIDEO_REGISTRY_KEY_FORMATS, hr, TRUE); if (SUCCEEDED(hr)) { for (int i = 0; i < Codec_VideoNB; ++i) { const codec_config_t *info = get_codec_config((LAVVideoCodec)i); @@ -241,7 +241,7 @@ HRESULT CLAVVideo::LoadSettings() } } - CRegistry regP = CRegistry(HKEY_CURRENT_USER, LAVC_VIDEO_REGISTRY_KEY_OUTPUT, hr); + CRegistry regP = CRegistry(HKEY_CURRENT_USER, LAVC_VIDEO_REGISTRY_KEY_OUTPUT, hr, TRUE); if (SUCCEEDED(hr)) { for (int i = 0; i < LAVOutPixFmt_NB; ++i) { bFlag = regP.ReadBOOL(pixFmtSettingsMap[i], hr); @@ -251,7 +251,7 @@ HRESULT CLAVVideo::LoadSettings() m_settings.bPixFmts[LAVOutPixFmt_YV16] = FALSE; } - CRegistry regHW = CRegistry(HKEY_CURRENT_USER, LAVC_VIDEO_REGISTRY_KEY_HWACCEL, hr); + CRegistry regHW = CRegistry(HKEY_CURRENT_USER, LAVC_VIDEO_REGISTRY_KEY_HWACCEL, hr, TRUE); if (SUCCEEDED(hr)) { dwVal = regHW.ReadDWORD(L"HWAccel", hr); if (SUCCEEDED(hr)) m_settings.HWAccel = dwVal; diff --git a/demuxer/LAVSplitter/LAVSplitter.cpp b/demuxer/LAVSplitter/LAVSplitter.cpp index 7c6ebc8f..ded9d1d2 100644 --- a/demuxer/LAVSplitter/LAVSplitter.cpp +++ b/demuxer/LAVSplitter/LAVSplitter.cpp @@ -162,7 +162,7 @@ STDMETHODIMP CLAVSplitter::LoadSettings() BOOL bFlag; std::wstring strVal; - CRegistry reg = CRegistry(HKEY_CURRENT_USER, LAVF_REGISTRY_KEY, hr); + CRegistry reg = CRegistry(HKEY_CURRENT_USER, LAVF_REGISTRY_KEY, hr, TRUE); if (SUCCEEDED(hr)) { // Language preferences strVal = reg.ReadString(L"prefAudioLangs", hr); @@ -203,7 +203,7 @@ STDMETHODIMP CLAVSplitter::LoadSettings() if (SUCCEEDED(hr)) m_settings.QueueMaxSize = dwVal; } - CRegistry regF = CRegistry(HKEY_CURRENT_USER, LAVF_REGISTRY_KEY_FORMATS, hr); + CRegistry regF = CRegistry(HKEY_CURRENT_USER, LAVF_REGISTRY_KEY_FORMATS, hr, TRUE); if (SUCCEEDED(hr)) { WCHAR wBuffer[80]; std::set<FormatInfo>::iterator it; |