- Fix problem with uTorrent deinstallation

- Closing of keys at list updating

svn path=/trunk/; revision=42946
This commit is contained in:
Dmitry Chapyshev 2009-08-26 19:03:32 +00:00
parent e7f2c45f58
commit d3bda8e821
3 changed files with 27 additions and 8 deletions

View 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;

View 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;

View 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);