diff --git a/reactos/base/applications/rapps/installed.c b/reactos/base/applications/rapps/installed.c index 61752c5be5d..5659e2db908 100644 --- a/reactos/base/applications/rapps/installed.c +++ b/reactos/base/applications/rapps/installed.c @@ -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; diff --git a/reactos/base/applications/rapps/rapps.h b/reactos/base/applications/rapps/rapps.h index 20faa9ccceb..bd98229aaeb 100644 --- a/reactos/base/applications/rapps/rapps.h +++ b/reactos/base/applications/rapps/rapps.h @@ -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; diff --git a/reactos/base/applications/rapps/winmain.c b/reactos/base/applications/rapps/winmain.c index 623ccb55296..f90411b81ed 100644 --- a/reactos/base/applications/rapps/winmain.c +++ b/reactos/base/applications/rapps/winmain.c @@ -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);