From 36e32bfa31731621ff2740018847c1124b79e741 Mon Sep 17 00:00:00 2001 From: Sup Yut Sum Date: Wed, 10 Apr 2013 08:16:48 +0800 Subject: [PATCH] Fix previous commit (could not remove the registry key) Signed-off-by: Sup Yut Sum --- src/TortoiseProc/Commands/DaemonCommand.cpp | 3 +-- src/Utils/MiscUI/MessageBox.cpp | 15 +++++++++++++++ src/Utils/MiscUI/MessageBox.h | 5 +++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/TortoiseProc/Commands/DaemonCommand.cpp b/src/TortoiseProc/Commands/DaemonCommand.cpp index dfa0c2888..fea40dd6b 100644 --- a/src/TortoiseProc/Commands/DaemonCommand.cpp +++ b/src/TortoiseProc/Commands/DaemonCommand.cpp @@ -21,14 +21,13 @@ #include "ProgressDlg.h" #include "UnicodeUtils.h" #include "MessageBox.h" -#include "registry.h" bool DaemonCommand::Execute() { if (CMessageBox::ShowCheck(NULL, IDS_DAEMON_SECURITY_WARN, IDS_APPNAME, 2, IDI_EXCLAMATION, IDS_PROCEEDBUTTON, IDS_ABORTBUTTON, NULL, _T("DaemonNoSecurityWarning"), IDS_MSGBOX_DONOTSHOWAGAIN) == 2) { - CRegStdDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\DaemonNoSecurityWarning")).removeValue(); // only store answer if it is "Proceed" + CMessageBox::RemoveRegistryKey(_T("DaemonNoSecurityWarning")); // only store answer if it is "Proceed" return false; } diff --git a/src/Utils/MiscUI/MessageBox.cpp b/src/Utils/MiscUI/MessageBox.cpp index e9cc58935..ab228a86f 100644 --- a/src/Utils/MiscUI/MessageBox.cpp +++ b/src/Utils/MiscUI/MessageBox.cpp @@ -243,6 +243,21 @@ UINT CMessageBox::Show(HWND hWnd, UINT nMessage, UINT nCaption, UINT uType, UINT return box.GoModal(CWnd::FromHandle(hWnd), sCaption, sMessage, box.FillBoxStandard(uType)); } +bool CMessageBox::RemoveRegistryKey(LPCTSTR lpRegistry) +{ + HKEY hKey; + CString path; +#ifdef XMESSAGEBOX_APPREGPATH + path = XMESSAGEBOX_APPREGPATH; +#else + path = "Software\\TortoiseGit\\"; + path += AfxGetAppName(); +#endif + if (RegOpenKeyEx(HKEY_CURRENT_USER, path, 0, KEY_WRITE, &hKey) == ERROR_SUCCESS) + return !!RegDeleteValue(hKey, lpRegistry); + return false; +} + int CMessageBox::FillBoxStandard(UINT uType) { int ret = 1; diff --git a/src/Utils/MiscUI/MessageBox.h b/src/Utils/MiscUI/MessageBox.h index fe66f3f89..f2aabee70 100644 --- a/src/Utils/MiscUI/MessageBox.h +++ b/src/Utils/MiscUI/MessageBox.h @@ -370,6 +370,11 @@ public: */ static UINT ShowCheck(HWND hWnd, UINT nMessage, UINT nCaption, int nDef, LPCTSTR icon, UINT nButton1, UINT nButton2, UINT nButton3, LPCTSTR lpRegistry, UINT nCheckMessage = NULL); + /** + * Removes the registry key + */ + static bool RemoveRegistryKey(LPCTSTR lpRegistry); + protected: /** * Stores the value in the registry -- 2.11.4.GIT