[RAPPS] CMainWindow: move RemoveAppFromRegistry in it
authorGiannis Adamopoulos <gadamopoulos@reactos.org>
Sun, 28 Apr 2019 03:45:12 +0000 (06:45 +0300)
committerMark Jansen <mark.jansen@reactos.org>
Mon, 19 Aug 2019 22:43:47 +0000 (00:43 +0200)
base/applications/rapps/gui.cpp
base/applications/rapps/installed.cpp

index 89eb62e..064ec4e 100644 (file)
@@ -1094,6 +1094,44 @@ private:
 
     }
 
+    VOID RemoveSelectedAppFromRegistry()
+    {
+        PINSTALLED_INFO Info;
+        WCHAR szFullName[MAX_PATH] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\";
+        ATL::CStringW szMsgText, szMsgTitle;
+        INT ItemIndex = m_ListView->GetNextItem(-1, LVNI_FOCUSED);
+
+        if (!IsInstalledEnum(SelectedEnumType))
+            return;
+
+        Info = reinterpret_cast<PINSTALLED_INFO>(m_ListView->GetItemData(ItemIndex));
+        if (!Info || !Info->hSubKey || (ItemIndex == -1)) 
+            return;
+
+        if (!szMsgText.LoadStringW(IDS_APP_REG_REMOVE) ||
+            !szMsgTitle.LoadStringW(IDS_INFORMATION))
+            return;
+
+        if (MessageBoxW(szMsgText, szMsgTitle, MB_YESNO | MB_ICONQUESTION) == IDYES)
+        {
+            ATL::CStringW::CopyChars(szFullName,
+                                     MAX_PATH,
+                                     Info->szKeyName.GetString(),
+                                     MAX_PATH - wcslen(szFullName));
+
+            if (RegDeleteKeyW(Info->hRootKey, szFullName) == ERROR_SUCCESS)
+            {
+                m_ListView->DeleteItem(ItemIndex);
+                return;
+            }
+
+            if (!szMsgText.LoadStringW(IDS_UNABLE_TO_REMOVE))
+                return;
+
+            MessageBoxW(szMsgText.GetString(), NULL, MB_OK | MB_ICONERROR);
+        }
+    }
+
     BOOL ProcessWindowMessage(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT& theResult, DWORD dwMapId)
     {
         theResult = 0;
@@ -1563,7 +1601,7 @@ private:
             break;
 
         case ID_REGREMOVE:
-            RemoveAppFromRegistry(-1);
+            RemoveSelectedAppFromRegistry();
             break;
 
         case ID_REFRESH:
index fb0bf03..cb53b88 100644 (file)
@@ -92,43 +92,6 @@ BOOL UninstallApplication(INT Index, BOOL bModify)
     return StartProcess(szPath, TRUE);
 }
 
-VOID RemoveAppFromRegistry(INT Index)
-{
-    PINSTALLED_INFO Info;
-    WCHAR szFullName[MAX_PATH] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\";
-    ATL::CStringW szMsgText, szMsgTitle;
-    INT ItemIndex = SendMessageW(hListView, LVM_GETNEXTITEM, -1, LVNI_FOCUSED);
-
-    if (!IsInstalledEnum(SelectedEnumType))
-        return;
-
-    Info = (PINSTALLED_INFO) ListViewGetlParam(Index);
-    if (!Info || !Info->hSubKey || (ItemIndex == -1)) return;
-
-    if (!szMsgText.LoadStringW(IDS_APP_REG_REMOVE) ||
-        !szMsgTitle.LoadStringW(IDS_INFORMATION))
-        return;
-
-    if (MessageBoxW(hMainWnd, szMsgText, szMsgTitle, MB_YESNO | MB_ICONQUESTION) == IDYES)
-    {
-        ATL::CStringW::CopyChars(szFullName,
-                                 MAX_PATH,
-                                 Info->szKeyName.GetString(),
-                                 MAX_PATH - wcslen(szFullName));
-
-        if (RegDeleteKeyW(Info->hRootKey, szFullName) == ERROR_SUCCESS)
-        {
-            ListView_DeleteItem(hListView, ItemIndex);
-            return;
-        }
-
-        if (!szMsgText.LoadStringW(IDS_UNABLE_TO_REMOVE))
-            return;
-
-        MessageBoxW(hMainWnd, szMsgText.GetString(), NULL, MB_OK | MB_ICONERROR);
-    }
-}
-
 BOOL EnumInstalledApplications(INT EnumType, BOOL IsUserKey, APPENUMPROC lpEnumProc, PVOID param)
 {
     DWORD dwSize = MAX_PATH, dwType, dwValue;