From da63b7edd77ed07e5123dbf5ac13777e6fe5c34f Mon Sep 17 00:00:00 2001 From: Perry Rapp Date: Fri, 7 Nov 2003 23:39:50 +0000 Subject: [PATCH] PATCH: [ 836931 ] Move QueryRegMachine into RegKey --- Src/Common/RegKey.cpp | 14 ++++++++++++++ Src/Common/RegKey.h | 2 ++ Src/MainFrm.cpp | 2 +- Src/VssPrompt.cpp | 3 ++- Src/readme.txt | 5 +++++ 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Src/Common/RegKey.cpp b/Src/Common/RegKey.cpp index 7bb264320..8dd33abdb 100644 --- a/Src/Common/RegKey.cpp +++ b/Src/Common/RegKey.cpp @@ -48,6 +48,20 @@ LONG CRegKeyEx::OpenNoCreateWithAccess(HKEY hKeyRoot, LPCTSTR pszPath, REGSAM re return RegOpenKeyEx (hKeyRoot, pszPath, 0L, regsam, &m_hKey); } +// Read-only open of registry key under HKEY_LOCAL_MACHINE +bool +CRegKeyEx::QueryRegMachine(LPCTSTR key) +{ + return OpenNoCreateWithAccess(HKEY_LOCAL_MACHINE, key, KEY_QUERY_VALUE) == ERROR_SUCCESS; +} + +// Read-only open of registry key under HKEY_CURRENT_USER +bool +CRegKeyEx::QueryRegUser(LPCTSTR key) +{ + return OpenNoCreateWithAccess(HKEY_CURRENT_USER, key, KEY_QUERY_VALUE) == ERROR_SUCCESS; +} + LONG CRegKeyEx::WriteDword (LPCTSTR pszKey, DWORD dwVal) { assert(m_hKey); diff --git a/Src/Common/RegKey.h b/Src/Common/RegKey.h index d5e51bacc..073ab630c 100644 --- a/Src/Common/RegKey.h +++ b/Src/Common/RegKey.h @@ -15,6 +15,8 @@ public: LONG Open(HKEY hKeyRoot, LPCTSTR pszPath); LONG OpenWithAccess(HKEY hKeyRoot, LPCTSTR pszPath, REGSAM regsam); LONG OpenNoCreateWithAccess(HKEY hKeyRoot, LPCTSTR pszPath, REGSAM regsam); + bool QueryRegMachine(LPCTSTR key); + bool QueryRegUser(LPCTSTR key); LONG WriteDword (LPCTSTR pszKey, DWORD dwVal); LONG WriteString (LPCTSTR pszKey, LPCTSTR pszVal); diff --git a/Src/MainFrm.cpp b/Src/MainFrm.cpp index b644d017b..b6cc8c6fc 100644 --- a/Src/MainFrm.cpp +++ b/Src/MainFrm.cpp @@ -173,7 +173,7 @@ CMainFrame::CMainFrame() if (m_strVssPath.IsEmpty()) { CRegKeyEx reg; - if (reg.Open(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\SourceSafe")) == ERROR_SUCCESS) + if (reg.QueryRegMachine(_T("SOFTWARE\\Microsoft\\SourceSafe"))) { TCHAR temp[_MAX_PATH] = {0}; reg.ReadChars(_T("SCCServerPath"), temp, _MAX_PATH, _T("")); diff --git a/Src/VssPrompt.cpp b/Src/VssPrompt.cpp index 55aec0fda..0a1d920c4 100644 --- a/Src/VssPrompt.cpp +++ b/Src/VssPrompt.cpp @@ -100,7 +100,8 @@ BOOL CVssPrompt::OnInitDialog() ZeroMemory(&cName, MAX_PATH * sizeof(TCHAR)); ZeroMemory(&cString, MAX_PATH * sizeof(TCHAR)); - reg.Open(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\SourceSafe\\Databases")); + if (!reg.QueryRegMachine(_T("SOFTWARE\\Microsoft\\SourceSafe\\Databases"))) + return false; HKEY hreg = reg.GetKey(); LONG retval = ERROR_SUCCESS; while (retval == ERROR_SUCCESS || retval == ERROR_MORE_DATA) diff --git a/Src/readme.txt b/Src/readme.txt index ba4b38eb5..1a96baa03 100644 --- a/Src/readme.txt +++ b/Src/readme.txt @@ -1,3 +1,8 @@ +2003-11-07 Perry + PATCH: [ 836931 ] Move QueryRegMachine into RegKey + common: RegKey.cpp RegKey.h + WinMerge: MainFrm.cpp VssPrompt.cpp + 2003-11-07 Laoran BUG: [ 837980 ] bug in save right as WinMerge: MergeDoc.cpp -- 2.11.0