- Fix problem with uTorrent deinstallation
authorDmitry Chapyshev <dmitry@reactos.org>
Wed, 26 Aug 2009 19:03:32 +0000 (19:03 +0000)
committerDmitry Chapyshev <dmitry@reactos.org>
Wed, 26 Aug 2009 19:03:32 +0000 (19:03 +0000)
- Closing of keys at list updating

svn path=/trunk/; revision=42946

reactos/base/applications/rapps/installed.c
reactos/base/applications/rapps/rapps.h
reactos/base/applications/rapps/winmain.c

index 61752c5..5659e2d 100644 (file)
@@ -31,7 +31,7 @@ GetApplicationString(HKEY hKey, LPWSTR lpKeyName, LPWSTR lpString)
 
 
 BOOL
-IsInstalledApplication(LPWSTR lpRegName)
+IsInstalledApplication(LPWSTR lpRegName, BOOL IsUserKey)
 {
     DWORD dwSize = MAX_PATH, dwType;
     WCHAR szName[MAX_PATH];
@@ -39,7 +39,7 @@ IsInstalledApplication(LPWSTR lpRegName)
     HKEY hKey, hSubKey;
     INT ItemIndex = 0;
 
-    if (RegOpenKeyW(HKEY_LOCAL_MACHINE,
+    if (RegOpenKeyW(IsUserKey ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE,
                     L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall",
                     &hKey) != ERROR_SUCCESS)
     {
@@ -247,7 +247,6 @@ EnumInstalledApplications(INT EnumType, BOOL IsUserKey, APPENUMPROC lpEnumProc)
         ItemIndex++;
     }
 
-    RegCloseKey(hSubKey);
     RegCloseKey(hKey);
 
     return TRUE;
index 20faa9c..bd98229 100644 (file)
@@ -80,7 +80,7 @@ BOOL EnumInstalledApplications(INT EnumType, BOOL IsUserKey, APPENUMPROC lpEnumP
 BOOL GetApplicationString(HKEY hKey, LPWSTR lpKeyName, LPWSTR lpString);
 BOOL ShowInstalledAppInfo(INT Index);
 BOOL UninstallApplication(INT Index, BOOL bModify);
-BOOL IsInstalledApplication(LPWSTR lpRegName);
+BOOL IsInstalledApplication(LPWSTR lpRegName, BOOL IsUserKey);
 
 /* winmain.c */
 extern HWND hMainWnd;
index 623ccb5..f90411b 100644 (file)
@@ -15,6 +15,21 @@ HIMAGELIST hImageTreeView = NULL;
 INT SelectedEnumType = ENUM_ALL_COMPONENTS;
 
 
+VOID
+FreeInstalledAppList(VOID)
+{
+    INT Count = ListView_GetItemCount(hListView) - 1;
+    HKEY hKey;
+
+    while (Count >= 0)
+    {
+        hKey = ListViewGetlParam(Count);
+        if (hKey)
+            RegCloseKey(hKey);
+        Count--;
+    }
+}
+
 BOOL
 CALLBACK
 EnumInstalledAppProc(INT ItemIndex, LPWSTR lpName, LPWSTR lpKeyName, LPARAM lParam)
@@ -56,7 +71,8 @@ EnumAvailableAppProc(APPLICATION_INFO Info)
     PAPPLICATION_INFO ItemInfo;
     INT Index;
 
-    if (!IsInstalledApplication(Info.szRegName))
+    if (!IsInstalledApplication(Info.szRegName, FALSE) &&
+        !IsInstalledApplication(Info.szRegName, TRUE))
     {
         ItemInfo = HeapAlloc(GetProcessHeap(), 0, sizeof(APPLICATION_INFO));
         if (!ItemInfo) return FALSE;
@@ -98,6 +114,11 @@ UpdateApplicationsList(INT EnumType)
 
     if (EnumType == -1) EnumType = SelectedEnumType;
 
+    if (IS_INSTALLED_ENUM(SelectedEnumType))
+        FreeInstalledAppList();
+    else if (IS_AVAILABLE_ENUM(SelectedEnumType))
+        FreeAvailableAppList();
+
     if (IS_INSTALLED_ENUM(EnumType))
     {
         /* Enum installed applications and updates */
@@ -106,9 +127,6 @@ UpdateApplicationsList(INT EnumType)
     }
     else if (IS_AVAILABLE_ENUM(EnumType))
     {
-        if (IS_AVAILABLE_ENUM(SelectedEnumType))
-            FreeAvailableAppList();
-
         /* Enum availabled applications */
         EnumAvailableApplications(EnumType, EnumAvailableAppProc);
     }
@@ -608,6 +626,8 @@ MainWindowProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
         {
             if (IS_AVAILABLE_ENUM(SelectedEnumType))
                 FreeAvailableAppList();
+            if (IS_INSTALLED_ENUM(SelectedEnumType))
+                FreeInstalledAppList();
             if (hImageListView) ImageList_Destroy(hImageListView);
             if (hImageTreeView) ImageList_Destroy(hImageTreeView);
             PostQuitMessage(0);