2008-07-24 22:57:28 +02:00
|
|
|
/*
|
|
|
|
* Add/Remove Programs applet
|
|
|
|
* Partially based on Wine Uninstaller
|
|
|
|
*
|
|
|
|
* Copyright 2000 Andreas Mohr
|
|
|
|
* Copyright 2004 Hannu Valtonen
|
|
|
|
* Copyright 2005 Jonathan Ernst
|
|
|
|
* Copyright 2001-2002, 2008 Owen Rudge
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2008-07-26 19:11:37 +02:00
|
|
|
#define NONAMELESSUNION
|
|
|
|
|
2008-07-24 22:57:28 +02:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <windef.h>
|
|
|
|
#include <winbase.h>
|
|
|
|
#include <winuser.h>
|
|
|
|
#include <wingdi.h>
|
|
|
|
#include <winreg.h>
|
|
|
|
#include <shellapi.h>
|
2008-07-21 20:42:07 +02:00
|
|
|
#include <commctrl.h>
|
2009-06-21 17:05:41 +02:00
|
|
|
#include <commdlg.h>
|
2008-07-24 22:57:28 +02:00
|
|
|
#include <cpl.h>
|
|
|
|
|
2010-12-24 14:51:03 +01:00
|
|
|
#include "wine/list.h"
|
|
|
|
#include "wine/debug.h"
|
2010-12-06 19:25:01 +01:00
|
|
|
#include "appwiz.h"
|
2008-07-24 22:57:28 +02:00
|
|
|
#include "res.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(appwizcpl);
|
|
|
|
|
2008-07-21 20:42:07 +02:00
|
|
|
/* define a maximum length for various buffers we use */
|
|
|
|
#define MAX_STRING_LEN 1024
|
|
|
|
|
2010-12-24 14:51:03 +01:00
|
|
|
typedef struct APPINFO
|
|
|
|
{
|
|
|
|
struct list entry;
|
2008-07-21 20:42:25 +02:00
|
|
|
int id;
|
|
|
|
|
|
|
|
LPWSTR title;
|
|
|
|
LPWSTR path;
|
2009-07-14 22:24:29 +02:00
|
|
|
LPWSTR path_modify;
|
2008-07-21 20:42:25 +02:00
|
|
|
|
|
|
|
LPWSTR icon;
|
|
|
|
int iconIdx;
|
|
|
|
|
|
|
|
LPWSTR publisher;
|
|
|
|
LPWSTR version;
|
2018-09-27 10:08:30 +02:00
|
|
|
LPWSTR contact;
|
|
|
|
LPWSTR helplink;
|
|
|
|
LPWSTR helptelephone;
|
|
|
|
LPWSTR readme;
|
|
|
|
LPWSTR urlupdateinfo;
|
|
|
|
LPWSTR comments;
|
2008-07-21 20:42:25 +02:00
|
|
|
|
|
|
|
HKEY regroot;
|
|
|
|
WCHAR regkey[MAX_STRING_LEN];
|
|
|
|
} APPINFO;
|
|
|
|
|
2010-12-24 14:51:03 +01:00
|
|
|
static struct list app_list = LIST_INIT( app_list );
|
2010-12-06 19:25:01 +01:00
|
|
|
HINSTANCE hInst;
|
2008-07-24 22:57:28 +02:00
|
|
|
|
2009-07-14 22:24:40 +02:00
|
|
|
static WCHAR btnRemove[MAX_STRING_LEN];
|
|
|
|
static WCHAR btnModifyRemove[MAX_STRING_LEN];
|
|
|
|
|
2020-11-01 23:31:58 +01:00
|
|
|
static const WCHAR PathUninstallW[] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall";
|
2008-07-21 20:42:25 +02:00
|
|
|
|
2008-07-24 22:57:28 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Name : DllMain
|
|
|
|
* Description: Entry point for DLL file
|
|
|
|
*/
|
|
|
|
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason,
|
|
|
|
LPVOID lpvReserved)
|
|
|
|
{
|
2022-02-07 23:10:58 +01:00
|
|
|
TRACE("(%p, %ld, %p)\n", hinstDLL, fdwReason, lpvReserved);
|
2008-07-24 22:57:28 +02:00
|
|
|
|
|
|
|
switch (fdwReason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
hInst = hinstDLL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-07-21 20:42:25 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Name : FreeAppInfo
|
|
|
|
* Description: Frees memory used by an AppInfo structure, and any children.
|
|
|
|
*/
|
|
|
|
static void FreeAppInfo(APPINFO *info)
|
|
|
|
{
|
2010-12-24 14:51:03 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, info->title);
|
|
|
|
HeapFree(GetProcessHeap(), 0, info->path);
|
|
|
|
HeapFree(GetProcessHeap(), 0, info->path_modify);
|
|
|
|
HeapFree(GetProcessHeap(), 0, info->icon);
|
|
|
|
HeapFree(GetProcessHeap(), 0, info->publisher);
|
|
|
|
HeapFree(GetProcessHeap(), 0, info->version);
|
2018-09-27 10:08:30 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, info->contact);
|
|
|
|
HeapFree(GetProcessHeap(), 0, info->helplink);
|
|
|
|
HeapFree(GetProcessHeap(), 0, info->helptelephone);
|
|
|
|
HeapFree(GetProcessHeap(), 0, info->readme);
|
|
|
|
HeapFree(GetProcessHeap(), 0, info->urlupdateinfo);
|
|
|
|
HeapFree(GetProcessHeap(), 0, info->comments);
|
2010-12-24 14:51:03 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, info);
|
2008-07-21 20:42:25 +02:00
|
|
|
}
|
|
|
|
|
2018-09-27 10:08:30 +02:00
|
|
|
static WCHAR *get_reg_str(HKEY hkey, const WCHAR *value)
|
|
|
|
{
|
|
|
|
DWORD len, type;
|
|
|
|
WCHAR *ret = NULL;
|
|
|
|
if (!RegQueryValueExW(hkey, value, NULL, &type, NULL, &len) && type == REG_SZ)
|
|
|
|
{
|
|
|
|
if (!(ret = HeapAlloc(GetProcessHeap(), 0, len))) return NULL;
|
|
|
|
RegQueryValueExW(hkey, value, 0, 0, (BYTE *)ret, &len);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-07-21 20:42:25 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Name : ReadApplicationsFromRegistry
|
|
|
|
* Description: Creates a linked list of uninstallable applications from the
|
|
|
|
* registry.
|
2011-02-22 13:23:19 +01:00
|
|
|
* Parameters : root - Which registry root to read from
|
2008-07-21 20:42:25 +02:00
|
|
|
* Returns : TRUE if successful, FALSE otherwise
|
|
|
|
*/
|
|
|
|
static BOOL ReadApplicationsFromRegistry(HKEY root)
|
|
|
|
{
|
2011-02-22 13:23:19 +01:00
|
|
|
HKEY hkeyApp;
|
2016-12-21 13:19:58 +01:00
|
|
|
int i;
|
|
|
|
static int id = 0;
|
2008-07-21 20:42:25 +02:00
|
|
|
DWORD sizeOfSubKeyName, displen, uninstlen;
|
2011-05-30 09:28:31 +02:00
|
|
|
DWORD dwNoModify, dwType, value, size;
|
2008-07-21 20:42:25 +02:00
|
|
|
WCHAR subKeyName[256];
|
2011-02-22 13:23:19 +01:00
|
|
|
WCHAR *command;
|
2010-12-24 14:51:03 +01:00
|
|
|
APPINFO *info = NULL;
|
2008-07-21 20:42:25 +02:00
|
|
|
LPWSTR iconPtr;
|
|
|
|
|
2018-03-21 02:59:11 +01:00
|
|
|
sizeOfSubKeyName = ARRAY_SIZE(subKeyName);
|
2008-07-21 20:42:25 +02:00
|
|
|
|
2011-02-22 13:23:19 +01:00
|
|
|
for (i = 0; RegEnumKeyExW(root, i, subKeyName, &sizeOfSubKeyName, NULL,
|
2008-07-21 20:42:25 +02:00
|
|
|
NULL, NULL, NULL) != ERROR_NO_MORE_ITEMS; ++i)
|
|
|
|
{
|
2011-02-22 13:23:19 +01:00
|
|
|
RegOpenKeyExW(root, subKeyName, 0, KEY_READ, &hkeyApp);
|
2011-05-30 09:28:31 +02:00
|
|
|
size = sizeof(value);
|
2020-11-01 23:31:58 +01:00
|
|
|
if (!RegQueryValueExW(hkeyApp, L"SystemComponent", NULL, &dwType, (BYTE *)&value, &size)
|
2011-05-30 09:28:31 +02:00
|
|
|
&& dwType == REG_DWORD && value == 1)
|
|
|
|
{
|
|
|
|
RegCloseKey(hkeyApp);
|
2018-03-21 02:59:11 +01:00
|
|
|
sizeOfSubKeyName = ARRAY_SIZE(subKeyName);
|
2011-05-30 09:28:31 +02:00
|
|
|
continue;
|
|
|
|
}
|
2008-07-21 20:42:25 +02:00
|
|
|
displen = 0;
|
|
|
|
uninstlen = 0;
|
2020-11-01 23:31:58 +01:00
|
|
|
if (!RegQueryValueExW(hkeyApp, L"DisplayName", 0, 0, NULL, &displen))
|
2008-07-21 20:42:25 +02:00
|
|
|
{
|
2011-05-30 09:28:31 +02:00
|
|
|
size = sizeof(value);
|
2020-11-01 23:31:58 +01:00
|
|
|
if (!RegQueryValueExW(hkeyApp, L"WindowsInstaller", NULL, &dwType, (BYTE *)&value, &size)
|
2010-12-24 09:38:08 +01:00
|
|
|
&& dwType == REG_DWORD && value == 1)
|
|
|
|
{
|
2020-11-01 23:31:58 +01:00
|
|
|
int len = lstrlenW(L"msiexec /x%s") + lstrlenW(subKeyName);
|
2010-12-24 09:38:08 +01:00
|
|
|
|
|
|
|
if (!(command = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)))) goto err;
|
2020-11-01 23:31:58 +01:00
|
|
|
wsprintfW(command, L"msiexec /x%s", subKeyName);
|
2010-12-24 09:38:08 +01:00
|
|
|
}
|
2020-11-01 23:31:58 +01:00
|
|
|
else if (!RegQueryValueExW(hkeyApp, L"UninstallString", 0, 0, NULL, &uninstlen))
|
2010-12-24 09:38:08 +01:00
|
|
|
{
|
|
|
|
if (!(command = HeapAlloc(GetProcessHeap(), 0, uninstlen))) goto err;
|
2020-11-01 23:31:58 +01:00
|
|
|
RegQueryValueExW(hkeyApp, L"UninstallString", 0, 0, (BYTE *)command, &uninstlen);
|
2010-12-24 09:38:08 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RegCloseKey(hkeyApp);
|
2018-03-21 02:59:11 +01:00
|
|
|
sizeOfSubKeyName = ARRAY_SIZE(subKeyName);
|
2010-12-24 09:38:08 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-12-24 14:51:03 +01:00
|
|
|
info = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct APPINFO));
|
|
|
|
if (!info) goto err;
|
2008-07-21 20:42:25 +02:00
|
|
|
|
2010-12-24 14:51:03 +01:00
|
|
|
info->title = HeapAlloc(GetProcessHeap(), 0, displen);
|
2008-07-21 20:42:25 +02:00
|
|
|
|
2010-12-24 14:51:03 +01:00
|
|
|
if (!info->title)
|
2008-07-21 20:42:25 +02:00
|
|
|
goto err;
|
|
|
|
|
2020-11-01 23:31:58 +01:00
|
|
|
RegQueryValueExW(hkeyApp, L"DisplayName", 0, 0, (BYTE *)info->title, &displen);
|
2008-07-21 20:42:25 +02:00
|
|
|
|
|
|
|
/* now get DisplayIcon */
|
|
|
|
displen = 0;
|
2020-11-01 23:31:58 +01:00
|
|
|
RegQueryValueExW(hkeyApp, L"DisplayIcon", 0, 0, NULL, &displen);
|
2008-07-21 20:42:25 +02:00
|
|
|
|
|
|
|
if (displen == 0)
|
2010-12-24 14:51:03 +01:00
|
|
|
info->icon = 0;
|
2008-07-21 20:42:25 +02:00
|
|
|
else
|
|
|
|
{
|
2010-12-24 14:51:03 +01:00
|
|
|
info->icon = HeapAlloc(GetProcessHeap(), 0, displen);
|
2008-07-21 20:42:25 +02:00
|
|
|
|
2010-12-24 14:51:03 +01:00
|
|
|
if (!info->icon)
|
2008-07-21 20:42:25 +02:00
|
|
|
goto err;
|
|
|
|
|
2020-11-01 23:31:58 +01:00
|
|
|
RegQueryValueExW(hkeyApp, L"DisplayIcon", 0, 0, (BYTE *)info->icon, &displen);
|
2008-07-21 20:42:25 +02:00
|
|
|
|
|
|
|
/* separate the index from the icon name, if supplied */
|
2019-07-05 11:12:36 +02:00
|
|
|
iconPtr = wcschr(info->icon, ',');
|
2008-07-21 20:42:25 +02:00
|
|
|
|
|
|
|
if (iconPtr)
|
|
|
|
{
|
|
|
|
*iconPtr++ = 0;
|
2019-07-05 11:12:36 +02:00
|
|
|
info->iconIdx = wcstol(iconPtr, NULL, 10);
|
2008-07-21 20:42:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-01 23:31:58 +01:00
|
|
|
info->publisher = get_reg_str(hkeyApp, L"Publisher");
|
|
|
|
info->version = get_reg_str(hkeyApp, L"DisplayVersion");
|
|
|
|
info->contact = get_reg_str(hkeyApp, L"Contact");
|
|
|
|
info->helplink = get_reg_str(hkeyApp, L"HelpLink");
|
|
|
|
info->helptelephone = get_reg_str(hkeyApp, L"HelpTelephone");
|
|
|
|
info->readme = get_reg_str(hkeyApp, L"Readme");
|
|
|
|
info->urlupdateinfo = get_reg_str(hkeyApp, L"URLUpdateInfo");
|
|
|
|
info->comments = get_reg_str(hkeyApp, L"Comments");
|
2008-07-21 20:42:25 +02:00
|
|
|
|
2009-07-14 22:24:29 +02:00
|
|
|
/* Check if NoModify is set */
|
|
|
|
dwType = REG_DWORD;
|
|
|
|
dwNoModify = 0;
|
|
|
|
displen = sizeof(DWORD);
|
|
|
|
|
2020-11-01 23:31:58 +01:00
|
|
|
if (RegQueryValueExW(hkeyApp, L"NoModify", NULL, &dwType, (BYTE *)&dwNoModify, &displen)
|
2009-07-14 22:24:29 +02:00
|
|
|
!= ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
dwNoModify = 0;
|
|
|
|
}
|
|
|
|
|
2010-12-24 14:51:03 +01:00
|
|
|
/* Some installers incorrectly create a REG_SZ instead of a REG_DWORD */
|
2009-07-14 22:24:29 +02:00
|
|
|
if (dwType == REG_SZ)
|
2010-12-24 14:51:03 +01:00
|
|
|
dwNoModify = (*(BYTE *)&dwNoModify == '1');
|
2009-07-14 22:24:29 +02:00
|
|
|
|
|
|
|
/* Fetch the modify path */
|
2010-12-24 09:38:08 +01:00
|
|
|
if (!dwNoModify)
|
2009-07-14 22:24:29 +02:00
|
|
|
{
|
2011-01-10 09:43:19 +01:00
|
|
|
size = sizeof(value);
|
2020-11-01 23:31:58 +01:00
|
|
|
if (!RegQueryValueExW(hkeyApp, L"WindowsInstaller", NULL, &dwType, (BYTE *)&value, &size)
|
2010-12-24 09:38:08 +01:00
|
|
|
&& dwType == REG_DWORD && value == 1)
|
|
|
|
{
|
2020-11-01 23:31:58 +01:00
|
|
|
int len = lstrlenW(L"msiexec /i%s") + lstrlenW(subKeyName);
|
2009-07-14 22:24:29 +02:00
|
|
|
|
2010-12-24 14:51:03 +01:00
|
|
|
if (!(info->path_modify = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)))) goto err;
|
2020-11-01 23:31:58 +01:00
|
|
|
wsprintfW(info->path_modify, L"msiexec /i%s", subKeyName);
|
2010-12-24 09:38:08 +01:00
|
|
|
}
|
2020-11-01 23:31:58 +01:00
|
|
|
else if (!RegQueryValueExW(hkeyApp, L"ModifyPath", 0, 0, NULL, &displen))
|
2010-12-24 09:38:08 +01:00
|
|
|
{
|
2010-12-24 14:51:03 +01:00
|
|
|
if (!(info->path_modify = HeapAlloc(GetProcessHeap(), 0, displen))) goto err;
|
2020-11-01 23:31:58 +01:00
|
|
|
RegQueryValueExW(hkeyApp, L"ModifyPath", 0, 0, (BYTE *)info->path_modify, &displen);
|
2010-12-24 09:38:08 +01:00
|
|
|
}
|
2009-07-14 22:24:29 +02:00
|
|
|
}
|
|
|
|
|
2008-07-21 20:42:25 +02:00
|
|
|
/* registry key */
|
2016-12-16 13:20:40 +01:00
|
|
|
RegOpenKeyExW(root, NULL, 0, KEY_READ, &info->regroot);
|
2010-12-24 14:51:03 +01:00
|
|
|
lstrcpyW(info->regkey, subKeyName);
|
|
|
|
info->path = command;
|
2008-07-21 20:42:25 +02:00
|
|
|
|
2010-12-24 14:51:03 +01:00
|
|
|
info->id = id++;
|
|
|
|
list_add_tail( &app_list, &info->entry );
|
2008-07-21 20:42:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(hkeyApp);
|
2018-03-21 02:59:11 +01:00
|
|
|
sizeOfSubKeyName = ARRAY_SIZE(subKeyName);
|
2008-07-21 20:42:25 +02:00
|
|
|
}
|
|
|
|
|
2011-02-22 13:23:19 +01:00
|
|
|
return TRUE;
|
2008-07-21 20:42:25 +02:00
|
|
|
err:
|
|
|
|
RegCloseKey(hkeyApp);
|
2010-12-24 14:51:03 +01:00
|
|
|
if (info) FreeAppInfo(info);
|
2012-12-26 18:28:22 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, command);
|
2011-02-22 13:23:19 +01:00
|
|
|
return FALSE;
|
2008-07-21 20:42:25 +02:00
|
|
|
}
|
|
|
|
|
2008-07-21 20:42:30 +02:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* Name : AddApplicationsToList
|
|
|
|
* Description: Populates the list box with applications.
|
|
|
|
* Parameters : hWnd - Handle of the dialog box
|
|
|
|
*/
|
|
|
|
static void AddApplicationsToList(HWND hWnd, HIMAGELIST hList)
|
|
|
|
{
|
2009-10-26 13:16:54 +01:00
|
|
|
APPINFO *iter;
|
2008-07-21 20:42:30 +02:00
|
|
|
LVITEMW lvItem;
|
|
|
|
HICON hIcon;
|
|
|
|
int index;
|
|
|
|
|
2010-12-24 14:51:03 +01:00
|
|
|
LIST_FOR_EACH_ENTRY( iter, &app_list, APPINFO, entry )
|
2008-07-21 20:42:30 +02:00
|
|
|
{
|
2009-10-26 13:16:54 +01:00
|
|
|
if (!iter->title[0]) continue;
|
|
|
|
|
2008-07-21 20:42:30 +02:00
|
|
|
/* get the icon */
|
|
|
|
index = 0;
|
|
|
|
|
|
|
|
if (iter->icon)
|
|
|
|
{
|
|
|
|
if (ExtractIconExW(iter->icon, iter->iconIdx, NULL, &hIcon, 1) == 1)
|
|
|
|
{
|
|
|
|
index = ImageList_AddIcon(hList, hIcon);
|
|
|
|
DestroyIcon(hIcon);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
lvItem.mask = LVIF_IMAGE | LVIF_TEXT | LVIF_PARAM;
|
|
|
|
lvItem.iItem = iter->id;
|
|
|
|
lvItem.iSubItem = 0;
|
|
|
|
lvItem.pszText = iter->title;
|
|
|
|
lvItem.iImage = index;
|
|
|
|
lvItem.lParam = iter->id;
|
|
|
|
|
|
|
|
index = ListView_InsertItemW(hWnd, &lvItem);
|
|
|
|
|
|
|
|
/* now add the subitems (columns) */
|
|
|
|
ListView_SetItemTextW(hWnd, index, 1, iter->publisher);
|
|
|
|
ListView_SetItemTextW(hWnd, index, 2, iter->version);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* Name : RemoveItemsFromList
|
|
|
|
* Description: Clears the application list box.
|
|
|
|
* Parameters : hWnd - Handle of the dialog box
|
|
|
|
*/
|
|
|
|
static void RemoveItemsFromList(HWND hWnd)
|
|
|
|
{
|
|
|
|
SendDlgItemMessageW(hWnd, IDL_PROGRAMS, LVM_DELETEALLITEMS, 0, 0);
|
|
|
|
}
|
|
|
|
|
2008-07-21 20:42:25 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Name : EmptyList
|
|
|
|
* Description: Frees memory used by the application linked list.
|
|
|
|
*/
|
|
|
|
static inline void EmptyList(void)
|
|
|
|
{
|
2010-12-24 14:51:03 +01:00
|
|
|
APPINFO *info, *next;
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE( info, next, &app_list, APPINFO, entry )
|
|
|
|
{
|
|
|
|
list_remove( &info->entry );
|
|
|
|
FreeAppInfo( info );
|
|
|
|
}
|
2008-07-21 20:42:25 +02:00
|
|
|
}
|
|
|
|
|
2008-07-21 20:42:21 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Name : UpdateButtons
|
|
|
|
* Description: Enables/disables the Add/Remove button depending on current
|
|
|
|
* selection in list box.
|
|
|
|
* Parameters : hWnd - Handle of the dialog box
|
|
|
|
*/
|
|
|
|
static void UpdateButtons(HWND hWnd)
|
|
|
|
{
|
2009-07-14 22:24:40 +02:00
|
|
|
APPINFO *iter;
|
|
|
|
LVITEMW lvItem;
|
2010-08-20 18:04:55 +02:00
|
|
|
LRESULT selitem = SendDlgItemMessageW(hWnd, IDL_PROGRAMS, LVM_GETNEXTITEM, -1,
|
2009-07-14 22:24:40 +02:00
|
|
|
LVNI_FOCUSED | LVNI_SELECTED);
|
|
|
|
BOOL enable_modify = FALSE;
|
|
|
|
|
|
|
|
if (selitem != -1)
|
|
|
|
{
|
|
|
|
lvItem.iItem = selitem;
|
|
|
|
lvItem.mask = LVIF_PARAM;
|
|
|
|
|
|
|
|
if (SendDlgItemMessageW(hWnd, IDL_PROGRAMS, LVM_GETITEMW, 0, (LPARAM) &lvItem))
|
|
|
|
{
|
2010-12-24 14:51:03 +01:00
|
|
|
LIST_FOR_EACH_ENTRY( iter, &app_list, APPINFO, entry )
|
2009-07-14 22:24:40 +02:00
|
|
|
{
|
|
|
|
if (iter->id == lvItem.lParam)
|
|
|
|
{
|
|
|
|
/* Decide whether to display Modify/Remove as one button or two */
|
|
|
|
enable_modify = (iter->path_modify != NULL);
|
|
|
|
|
|
|
|
/* Update title as appropriate */
|
|
|
|
if (iter->path_modify == NULL)
|
|
|
|
SetWindowTextW(GetDlgItem(hWnd, IDC_ADDREMOVE), btnModifyRemove);
|
|
|
|
else
|
|
|
|
SetWindowTextW(GetDlgItem(hWnd, IDC_ADDREMOVE), btnRemove);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-07-21 20:42:21 +02:00
|
|
|
|
2009-07-14 22:24:40 +02:00
|
|
|
/* Enable/disable other buttons if necessary */
|
|
|
|
EnableWindow(GetDlgItem(hWnd, IDC_ADDREMOVE), (selitem != -1));
|
|
|
|
EnableWindow(GetDlgItem(hWnd, IDC_SUPPORT_INFO), (selitem != -1));
|
|
|
|
EnableWindow(GetDlgItem(hWnd, IDC_MODIFY), enable_modify);
|
2008-07-21 20:42:21 +02:00
|
|
|
}
|
|
|
|
|
2009-06-21 17:05:41 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Name : InstallProgram
|
|
|
|
* Description: Search for potential Installer and execute it.
|
|
|
|
* Parameters : hWnd - Handle of the dialog box
|
|
|
|
*/
|
|
|
|
static void InstallProgram(HWND hWnd)
|
|
|
|
{
|
|
|
|
OPENFILENAMEW ofn;
|
|
|
|
WCHAR titleW[MAX_STRING_LEN];
|
2011-01-13 12:20:14 +01:00
|
|
|
WCHAR filter_installs[MAX_STRING_LEN];
|
|
|
|
WCHAR filter_programs[MAX_STRING_LEN];
|
|
|
|
WCHAR filter_all[MAX_STRING_LEN];
|
|
|
|
WCHAR FilterBufferW[MAX_PATH];
|
2009-06-21 17:05:41 +02:00
|
|
|
WCHAR FileNameBufferW[MAX_PATH];
|
|
|
|
|
2018-03-29 17:14:13 +02:00
|
|
|
LoadStringW(hInst, IDS_CPL_TITLE, titleW, ARRAY_SIZE(titleW));
|
|
|
|
LoadStringW(hInst, IDS_FILTER_INSTALLS, filter_installs, ARRAY_SIZE(filter_installs));
|
|
|
|
LoadStringW(hInst, IDS_FILTER_PROGRAMS, filter_programs, ARRAY_SIZE(filter_programs));
|
|
|
|
LoadStringW(hInst, IDS_FILTER_ALL, filter_all, ARRAY_SIZE(filter_all));
|
2009-06-21 17:05:41 +02:00
|
|
|
|
2020-11-01 23:31:58 +01:00
|
|
|
swprintf( FilterBufferW, MAX_PATH, L"%s%c*instal*.exe;*setup*.exe;*.msi%c%s%c*.exe%c%s%c*.*%c",
|
|
|
|
filter_installs, 0, 0, filter_programs, 0, 0, filter_all, 0, 0 );
|
2009-06-21 17:05:41 +02:00
|
|
|
memset(&ofn, 0, sizeof(OPENFILENAMEW));
|
|
|
|
ofn.lStructSize = sizeof(OPENFILENAMEW);
|
|
|
|
ofn.hwndOwner = hWnd;
|
|
|
|
ofn.hInstance = hInst;
|
|
|
|
ofn.lpstrFilter = FilterBufferW;
|
|
|
|
ofn.nFilterIndex = 0;
|
|
|
|
ofn.lpstrFile = FileNameBufferW;
|
|
|
|
ofn.nMaxFile = MAX_PATH;
|
|
|
|
ofn.lpstrFileTitle = NULL;
|
|
|
|
ofn.nMaxFileTitle = 0;
|
|
|
|
ofn.lpstrTitle = titleW;
|
|
|
|
ofn.Flags = OFN_HIDEREADONLY | OFN_ENABLESIZING;
|
|
|
|
FileNameBufferW[0] = 0;
|
|
|
|
|
|
|
|
if (GetOpenFileNameW(&ofn))
|
|
|
|
{
|
|
|
|
SHELLEXECUTEINFOW sei;
|
|
|
|
memset(&sei, 0, sizeof(sei));
|
|
|
|
sei.cbSize = sizeof(sei);
|
2020-11-01 23:31:58 +01:00
|
|
|
sei.lpVerb = L"open";
|
2009-06-21 17:05:41 +02:00
|
|
|
sei.nShow = SW_SHOWDEFAULT;
|
2014-04-22 19:52:10 +02:00
|
|
|
sei.fMask = 0;
|
2009-06-21 17:05:41 +02:00
|
|
|
sei.lpFile = ofn.lpstrFile;
|
|
|
|
|
|
|
|
ShellExecuteExW(&sei);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-21 20:42:38 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Name : UninstallProgram
|
|
|
|
* Description: Executes the specified program's installer.
|
|
|
|
* Parameters : id - the internal ID of the installer to remove
|
2009-07-14 22:24:51 +02:00
|
|
|
* Parameters : button - ID of button pressed (Modify or Remove)
|
2008-07-21 20:42:38 +02:00
|
|
|
*/
|
2009-07-14 22:24:51 +02:00
|
|
|
static void UninstallProgram(int id, DWORD button)
|
2008-07-21 20:42:38 +02:00
|
|
|
{
|
|
|
|
APPINFO *iter;
|
|
|
|
STARTUPINFOW si;
|
|
|
|
PROCESS_INFORMATION info;
|
|
|
|
WCHAR errormsg[MAX_STRING_LEN];
|
|
|
|
WCHAR sUninstallFailed[MAX_STRING_LEN];
|
|
|
|
BOOL res;
|
|
|
|
|
|
|
|
LoadStringW(hInst, IDS_UNINSTALL_FAILED, sUninstallFailed,
|
2018-03-21 02:59:11 +01:00
|
|
|
ARRAY_SIZE(sUninstallFailed));
|
2008-07-21 20:42:38 +02:00
|
|
|
|
2010-12-24 14:51:03 +01:00
|
|
|
LIST_FOR_EACH_ENTRY( iter, &app_list, APPINFO, entry )
|
2008-07-21 20:42:38 +02:00
|
|
|
{
|
|
|
|
if (iter->id == id)
|
|
|
|
{
|
|
|
|
TRACE("Uninstalling %s (%s)\n", wine_dbgstr_w(iter->title),
|
|
|
|
wine_dbgstr_w(iter->path));
|
|
|
|
|
|
|
|
memset(&si, 0, sizeof(STARTUPINFOW));
|
|
|
|
si.cb = sizeof(STARTUPINFOW);
|
|
|
|
si.wShowWindow = SW_NORMAL;
|
2009-07-14 22:24:51 +02:00
|
|
|
|
|
|
|
res = CreateProcessW(NULL, (button == IDC_MODIFY) ? iter->path_modify : iter->path,
|
|
|
|
NULL, NULL, FALSE, 0, NULL, NULL, &si, &info);
|
2008-07-21 20:42:38 +02:00
|
|
|
|
|
|
|
if (res)
|
|
|
|
{
|
2008-08-17 19:26:21 +02:00
|
|
|
CloseHandle(info.hThread);
|
|
|
|
|
2008-07-21 20:42:38 +02:00
|
|
|
/* wait for the process to exit */
|
|
|
|
WaitForSingleObject(info.hProcess, INFINITE);
|
2008-08-17 19:26:21 +02:00
|
|
|
CloseHandle(info.hProcess);
|
2008-07-21 20:42:38 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wsprintfW(errormsg, sUninstallFailed, iter->path);
|
|
|
|
|
|
|
|
if (MessageBoxW(0, errormsg, iter->title, MB_YESNO |
|
|
|
|
MB_ICONQUESTION) == IDYES)
|
|
|
|
{
|
|
|
|
/* delete the application's uninstall entry */
|
2016-12-16 13:20:40 +01:00
|
|
|
RegDeleteKeyW(iter->regroot, iter->regkey);
|
|
|
|
RegCloseKey(iter->regroot);
|
2008-07-21 20:42:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-28 16:16:35 +02:00
|
|
|
/**********************************************************************************
|
|
|
|
* Name : SetInfoDialogText
|
|
|
|
* Description: Sets the text of a label in a window, based upon a registry entry
|
|
|
|
* or string passed to the function.
|
|
|
|
* Parameters : hKey - registry entry to read from, NULL if not reading
|
|
|
|
* from registry
|
|
|
|
* lpKeyName - key to read from, or string to check if hKey is NULL
|
|
|
|
* lpAltMessage - alternative message if entry not found
|
|
|
|
* hWnd - handle of dialog box
|
|
|
|
* iDlgItem - ID of label in dialog box
|
|
|
|
*/
|
2010-03-26 17:17:28 +01:00
|
|
|
static void SetInfoDialogText(HKEY hKey, LPCWSTR lpKeyName, LPCWSTR lpAltMessage,
|
2008-07-28 16:16:35 +02:00
|
|
|
HWND hWnd, int iDlgItem)
|
|
|
|
{
|
|
|
|
WCHAR buf[MAX_STRING_LEN];
|
|
|
|
DWORD buflen;
|
|
|
|
HWND hWndDlgItem;
|
|
|
|
|
|
|
|
hWndDlgItem = GetDlgItem(hWnd, iDlgItem);
|
|
|
|
|
|
|
|
/* if hKey is null, lpKeyName contains the string we want to check */
|
|
|
|
if (hKey == NULL)
|
|
|
|
{
|
2014-11-14 10:51:38 +01:00
|
|
|
if (lpKeyName && lpKeyName[0])
|
2008-07-28 16:16:35 +02:00
|
|
|
SetWindowTextW(hWndDlgItem, lpKeyName);
|
|
|
|
else
|
|
|
|
SetWindowTextW(hWndDlgItem, lpAltMessage);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-19 10:30:31 +02:00
|
|
|
buflen = sizeof(buf);
|
2008-07-28 16:16:35 +02:00
|
|
|
|
|
|
|
if ((RegQueryValueExW(hKey, lpKeyName, 0, 0, (LPBYTE) buf, &buflen) ==
|
2014-11-14 10:51:38 +01:00
|
|
|
ERROR_SUCCESS) && buf[0])
|
2008-07-28 16:16:35 +02:00
|
|
|
SetWindowTextW(hWndDlgItem, buf);
|
|
|
|
else
|
|
|
|
SetWindowTextW(hWndDlgItem, lpAltMessage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-21 20:44:02 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Name : SupportInfoDlgProc
|
|
|
|
* Description: Callback procedure for support info dialog
|
|
|
|
* Parameters : hWnd - hWnd of the window
|
|
|
|
* msg - reason for calling function
|
|
|
|
* wParam - additional parameter
|
|
|
|
* lParam - additional parameter
|
2012-05-15 10:15:32 +02:00
|
|
|
* Returns : Depends on the message
|
2008-07-21 20:44:02 +02:00
|
|
|
*/
|
2012-11-19 09:28:43 +01:00
|
|
|
static INT_PTR CALLBACK SupportInfoDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
2008-07-21 20:44:02 +02:00
|
|
|
{
|
|
|
|
APPINFO *iter;
|
2008-07-28 16:16:35 +02:00
|
|
|
HKEY hkey;
|
2008-07-21 20:44:02 +02:00
|
|
|
WCHAR oldtitle[MAX_STRING_LEN];
|
|
|
|
WCHAR buf[MAX_STRING_LEN];
|
2008-07-28 16:16:35 +02:00
|
|
|
WCHAR key[MAX_STRING_LEN];
|
|
|
|
WCHAR notfound[MAX_STRING_LEN];
|
2008-07-21 20:44:02 +02:00
|
|
|
|
|
|
|
switch(msg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
2010-12-24 14:51:03 +01:00
|
|
|
LIST_FOR_EACH_ENTRY( iter, &app_list, APPINFO, entry )
|
2008-07-21 20:44:02 +02:00
|
|
|
{
|
|
|
|
if (iter->id == (int) lParam)
|
|
|
|
{
|
2008-07-28 16:16:35 +02:00
|
|
|
lstrcpyW(key, PathUninstallW);
|
2020-11-01 23:31:58 +01:00
|
|
|
lstrcatW(key, L"\\");
|
2008-07-28 16:16:35 +02:00
|
|
|
lstrcatW(key, iter->regkey);
|
|
|
|
|
|
|
|
/* check the application's registry entries */
|
|
|
|
RegOpenKeyExW(iter->regroot, key, 0, KEY_READ, &hkey);
|
|
|
|
|
|
|
|
/* Load our "not specified" string */
|
2018-09-27 10:08:30 +02:00
|
|
|
LoadStringW(hInst, IDS_NOT_SPECIFIED, notfound, ARRAY_SIZE(notfound));
|
|
|
|
|
|
|
|
SetInfoDialogText(NULL, iter->publisher, notfound, hWnd, IDC_INFO_PUBLISHER);
|
|
|
|
SetInfoDialogText(NULL, iter->version, notfound, hWnd, IDC_INFO_VERSION);
|
|
|
|
SetInfoDialogText(hkey, iter->contact, notfound, hWnd, IDC_INFO_CONTACT);
|
|
|
|
SetInfoDialogText(hkey, iter->helplink, notfound, hWnd, IDC_INFO_SUPPORT);
|
|
|
|
SetInfoDialogText(hkey, iter->helptelephone, notfound, hWnd, IDC_INFO_PHONE);
|
|
|
|
SetInfoDialogText(hkey, iter->readme, notfound, hWnd, IDC_INFO_README);
|
|
|
|
SetInfoDialogText(hkey, iter->urlupdateinfo, notfound, hWnd, IDC_INFO_UPDATES);
|
|
|
|
SetInfoDialogText(hkey, iter->comments, notfound, hWnd, IDC_INFO_COMMENTS);
|
2008-07-28 16:16:35 +02:00
|
|
|
|
2008-07-21 20:44:02 +02:00
|
|
|
/* Update the main label with the app name */
|
|
|
|
if (GetWindowTextW(GetDlgItem(hWnd, IDC_INFO_LABEL), oldtitle,
|
|
|
|
MAX_STRING_LEN) != 0)
|
|
|
|
{
|
|
|
|
wsprintfW(buf, oldtitle, iter->title);
|
|
|
|
SetWindowTextW(GetDlgItem(hWnd, IDC_INFO_LABEL), buf);
|
|
|
|
}
|
|
|
|
|
2008-07-28 16:16:35 +02:00
|
|
|
RegCloseKey(hkey);
|
|
|
|
|
2008-07-21 20:44:02 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case WM_DESTROY:
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD(wParam))
|
|
|
|
{
|
|
|
|
case IDOK:
|
|
|
|
EndDialog(hWnd, TRUE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* Name : SupportInfo
|
|
|
|
* Description: Displays the Support Information dialog
|
|
|
|
* Parameters : hWnd - Handle of the main dialog
|
|
|
|
* id - ID of the application to display information for
|
|
|
|
*/
|
|
|
|
static void SupportInfo(HWND hWnd, int id)
|
|
|
|
{
|
2012-11-19 09:28:43 +01:00
|
|
|
DialogBoxParamW(hInst, MAKEINTRESOURCEW(IDD_INFO), hWnd, SupportInfoDlgProc, id);
|
2008-07-21 20:44:02 +02:00
|
|
|
}
|
|
|
|
|
2008-07-21 20:42:12 +02:00
|
|
|
/* Definition of column headers for AddListViewColumns function */
|
|
|
|
typedef struct AppWizColumn {
|
|
|
|
int width;
|
|
|
|
int fmt;
|
|
|
|
int title;
|
|
|
|
} AppWizColumn;
|
|
|
|
|
2008-11-12 08:15:32 +01:00
|
|
|
static const AppWizColumn columns[] = {
|
2008-07-21 20:42:12 +02:00
|
|
|
{200, LVCFMT_LEFT, IDS_COLUMN_NAME},
|
|
|
|
{150, LVCFMT_LEFT, IDS_COLUMN_PUBLISHER},
|
|
|
|
{100, LVCFMT_LEFT, IDS_COLUMN_VERSION},
|
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* Name : AddListViewColumns
|
|
|
|
* Description: Adds column headers to the list view control.
|
|
|
|
* Parameters : hWnd - Handle of the list view control.
|
|
|
|
* Returns : TRUE if completed successfully, FALSE otherwise.
|
|
|
|
*/
|
|
|
|
static BOOL AddListViewColumns(HWND hWnd)
|
|
|
|
{
|
|
|
|
WCHAR buf[MAX_STRING_LEN];
|
|
|
|
LVCOLUMNW lvc;
|
2008-07-26 22:46:45 +02:00
|
|
|
UINT i;
|
2008-07-21 20:42:12 +02:00
|
|
|
|
|
|
|
lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH;
|
|
|
|
|
|
|
|
/* Add the columns */
|
2018-03-21 02:59:11 +01:00
|
|
|
for (i = 0; i < ARRAY_SIZE(columns); i++)
|
2008-07-21 20:42:12 +02:00
|
|
|
{
|
|
|
|
lvc.iSubItem = i;
|
|
|
|
lvc.pszText = buf;
|
|
|
|
|
|
|
|
/* set width and format */
|
|
|
|
lvc.cx = columns[i].width;
|
|
|
|
lvc.fmt = columns[i].fmt;
|
|
|
|
|
2018-03-21 02:59:11 +01:00
|
|
|
LoadStringW(hInst, columns[i].title, buf, ARRAY_SIZE(buf));
|
2008-07-21 20:42:12 +02:00
|
|
|
|
|
|
|
if (ListView_InsertColumnW(hWnd, i, &lvc) == -1)
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-07-21 20:42:16 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Name : AddListViewImageList
|
|
|
|
* Description: Creates an ImageList for the list view control.
|
|
|
|
* Parameters : hWnd - Handle of the list view control.
|
|
|
|
* Returns : Handle of the image list.
|
|
|
|
*/
|
|
|
|
static HIMAGELIST AddListViewImageList(HWND hWnd)
|
|
|
|
{
|
|
|
|
HIMAGELIST hSmall;
|
|
|
|
HICON hDefaultIcon;
|
|
|
|
|
|
|
|
hSmall = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON),
|
2010-06-13 16:50:49 +02:00
|
|
|
ILC_COLOR32 | ILC_MASK, 1, 1);
|
2008-07-21 20:42:16 +02:00
|
|
|
|
|
|
|
/* Add default icon to image list */
|
|
|
|
hDefaultIcon = LoadIconW(hInst, MAKEINTRESOURCEW(ICO_MAIN));
|
|
|
|
ImageList_AddIcon(hSmall, hDefaultIcon);
|
|
|
|
DestroyIcon(hDefaultIcon);
|
|
|
|
|
2009-05-10 10:11:53 +02:00
|
|
|
SendMessageW(hWnd, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)hSmall);
|
2008-07-21 20:42:16 +02:00
|
|
|
|
|
|
|
return hSmall;
|
|
|
|
}
|
|
|
|
|
2008-07-21 20:42:12 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Name : ResetApplicationList
|
|
|
|
* Description: Empties the app list, if need be, and recreates it.
|
|
|
|
* Parameters : bFirstRun - TRUE if this is the first time this is run, FALSE otherwise
|
|
|
|
* hWnd - handle of the dialog box
|
|
|
|
* hImageList - handle of the image list
|
|
|
|
* Returns : New handle of the image list.
|
|
|
|
*/
|
|
|
|
static HIMAGELIST ResetApplicationList(BOOL bFirstRun, HWND hWnd, HIMAGELIST hImageList)
|
|
|
|
{
|
2011-02-22 13:23:19 +01:00
|
|
|
static const BOOL is_64bit = sizeof(void *) > sizeof(int);
|
2008-07-21 20:42:12 +02:00
|
|
|
HWND hWndListView;
|
2011-02-22 13:23:19 +01:00
|
|
|
HKEY hkey;
|
2008-07-21 20:42:12 +02:00
|
|
|
|
|
|
|
hWndListView = GetDlgItem(hWnd, IDL_PROGRAMS);
|
|
|
|
|
|
|
|
/* if first run, create the image list and add the listview columns */
|
|
|
|
if (bFirstRun)
|
|
|
|
{
|
|
|
|
if (!AddListViewColumns(hWndListView))
|
|
|
|
return NULL;
|
|
|
|
}
|
2008-07-21 20:42:16 +02:00
|
|
|
else /* we need to remove the existing things first */
|
|
|
|
{
|
2008-07-21 20:42:30 +02:00
|
|
|
RemoveItemsFromList(hWnd);
|
2008-07-21 20:42:16 +02:00
|
|
|
ImageList_Destroy(hImageList);
|
2008-07-21 20:42:25 +02:00
|
|
|
|
|
|
|
/* reset the list, since it's probably changed if the uninstallation was
|
|
|
|
successful */
|
|
|
|
EmptyList();
|
2008-07-21 20:42:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* now create the image list and add the applications to the listview */
|
|
|
|
hImageList = AddListViewImageList(hWndListView);
|
2008-07-21 20:42:12 +02:00
|
|
|
|
2011-02-22 13:23:19 +01:00
|
|
|
if (!RegOpenKeyExW(HKEY_LOCAL_MACHINE, PathUninstallW, 0, KEY_READ, &hkey))
|
|
|
|
{
|
|
|
|
ReadApplicationsFromRegistry(hkey);
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
|
|
|
if (is_64bit &&
|
|
|
|
!RegOpenKeyExW(HKEY_LOCAL_MACHINE, PathUninstallW, 0, KEY_READ|KEY_WOW64_32KEY, &hkey))
|
|
|
|
{
|
|
|
|
ReadApplicationsFromRegistry(hkey);
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
|
|
|
if (!RegOpenKeyExW(HKEY_CURRENT_USER, PathUninstallW, 0, KEY_READ, &hkey))
|
|
|
|
{
|
|
|
|
ReadApplicationsFromRegistry(hkey);
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
2008-07-21 20:42:25 +02:00
|
|
|
|
2008-07-21 20:42:30 +02:00
|
|
|
AddApplicationsToList(hWndListView, hImageList);
|
2008-07-21 20:42:21 +02:00
|
|
|
UpdateButtons(hWnd);
|
|
|
|
|
2008-07-21 20:42:12 +02:00
|
|
|
return(hImageList);
|
|
|
|
}
|
|
|
|
|
2008-07-21 20:42:07 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Name : MainDlgProc
|
|
|
|
* Description: Callback procedure for main tab
|
|
|
|
* Parameters : hWnd - hWnd of the window
|
|
|
|
* msg - reason for calling function
|
|
|
|
* wParam - additional parameter
|
|
|
|
* lParam - additional parameter
|
2012-05-15 10:15:32 +02:00
|
|
|
* Returns : Depends on the message
|
2008-07-21 20:42:07 +02:00
|
|
|
*/
|
2012-11-19 09:28:43 +01:00
|
|
|
static INT_PTR CALLBACK MainDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
2008-07-21 20:42:07 +02:00
|
|
|
{
|
2008-07-21 20:42:38 +02:00
|
|
|
int selitem;
|
2008-07-21 20:42:12 +02:00
|
|
|
static HIMAGELIST hImageList;
|
2008-07-21 20:42:30 +02:00
|
|
|
LPNMHDR nmh;
|
2008-07-21 20:42:38 +02:00
|
|
|
LVITEMW lvItem;
|
2008-07-21 20:42:12 +02:00
|
|
|
|
|
|
|
switch(msg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
2017-05-18 14:19:34 +02:00
|
|
|
SendDlgItemMessageW(hWnd, IDL_PROGRAMS, LVM_SETEXTENDEDLISTVIEWSTYLE,
|
|
|
|
LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT);
|
|
|
|
|
2008-07-21 20:42:12 +02:00
|
|
|
hImageList = ResetApplicationList(TRUE, hWnd, hImageList);
|
|
|
|
|
2008-07-21 20:42:16 +02:00
|
|
|
if (!hImageList)
|
|
|
|
return FALSE;
|
|
|
|
|
2008-07-21 20:42:12 +02:00
|
|
|
return TRUE;
|
2008-07-21 20:42:16 +02:00
|
|
|
|
|
|
|
case WM_DESTROY:
|
2008-07-21 20:42:30 +02:00
|
|
|
RemoveItemsFromList(hWnd);
|
2008-07-21 20:42:16 +02:00
|
|
|
ImageList_Destroy(hImageList);
|
|
|
|
|
2008-07-21 20:42:25 +02:00
|
|
|
EmptyList();
|
|
|
|
|
2008-07-21 20:42:16 +02:00
|
|
|
return 0;
|
2008-07-21 20:42:30 +02:00
|
|
|
|
|
|
|
case WM_NOTIFY:
|
|
|
|
nmh = (LPNMHDR) lParam;
|
|
|
|
|
|
|
|
switch (nmh->idFrom)
|
|
|
|
{
|
|
|
|
case IDL_PROGRAMS:
|
|
|
|
switch (nmh->code)
|
|
|
|
{
|
|
|
|
case LVN_ITEMCHANGED:
|
|
|
|
UpdateButtons(hWnd);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-07-21 20:42:38 +02:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD(wParam))
|
|
|
|
{
|
2009-06-21 17:05:41 +02:00
|
|
|
case IDC_INSTALL:
|
|
|
|
InstallProgram(hWnd);
|
|
|
|
break;
|
|
|
|
|
2008-07-21 20:42:38 +02:00
|
|
|
case IDC_ADDREMOVE:
|
2009-07-14 22:24:51 +02:00
|
|
|
case IDC_MODIFY:
|
2008-07-21 20:42:38 +02:00
|
|
|
selitem = SendDlgItemMessageW(hWnd, IDL_PROGRAMS,
|
|
|
|
LVM_GETNEXTITEM, -1, LVNI_FOCUSED|LVNI_SELECTED);
|
|
|
|
|
|
|
|
if (selitem != -1)
|
|
|
|
{
|
|
|
|
lvItem.iItem = selitem;
|
|
|
|
lvItem.mask = LVIF_PARAM;
|
|
|
|
|
|
|
|
if (SendDlgItemMessageW(hWnd, IDL_PROGRAMS, LVM_GETITEMW,
|
|
|
|
0, (LPARAM) &lvItem))
|
2009-07-14 22:24:51 +02:00
|
|
|
UninstallProgram(lvItem.lParam, LOWORD(wParam));
|
2008-07-21 20:42:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
hImageList = ResetApplicationList(FALSE, hWnd, hImageList);
|
|
|
|
|
2008-07-21 20:44:02 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDC_SUPPORT_INFO:
|
|
|
|
selitem = SendDlgItemMessageW(hWnd, IDL_PROGRAMS,
|
|
|
|
LVM_GETNEXTITEM, -1, LVNI_FOCUSED | LVNI_SELECTED);
|
|
|
|
|
|
|
|
if (selitem != -1)
|
|
|
|
{
|
|
|
|
lvItem.iItem = selitem;
|
|
|
|
lvItem.mask = LVIF_PARAM;
|
|
|
|
|
|
|
|
if (SendDlgItemMessageW(hWnd, IDL_PROGRAMS, LVM_GETITEMW,
|
|
|
|
0, (LPARAM) &lvItem))
|
|
|
|
SupportInfo(hWnd, lvItem.lParam);
|
|
|
|
}
|
|
|
|
|
2008-07-21 20:42:38 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-07-21 20:42:30 +02:00
|
|
|
return TRUE;
|
2008-07-21 20:42:12 +02:00
|
|
|
}
|
|
|
|
|
2008-07-21 20:42:07 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2010-04-16 16:24:28 +02:00
|
|
|
static int CALLBACK propsheet_callback( HWND hwnd, UINT msg, LPARAM lparam )
|
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case PSCB_INITIALIZED:
|
|
|
|
SendMessageW( hwnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIconW( hInst, MAKEINTRESOURCEW(ICO_MAIN) ));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-07-21 20:42:07 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Name : StartApplet
|
|
|
|
* Description: Main routine for applet
|
|
|
|
* Parameters : hWnd - hWnd of the Control Panel
|
|
|
|
*/
|
|
|
|
static void StartApplet(HWND hWnd)
|
|
|
|
{
|
|
|
|
PROPSHEETPAGEW psp;
|
|
|
|
PROPSHEETHEADERW psh;
|
|
|
|
WCHAR tab_title[MAX_STRING_LEN], app_title[MAX_STRING_LEN];
|
|
|
|
|
|
|
|
/* Load the strings we will use */
|
2018-03-21 02:59:11 +01:00
|
|
|
LoadStringW(hInst, IDS_TAB1_TITLE, tab_title, ARRAY_SIZE(tab_title));
|
|
|
|
LoadStringW(hInst, IDS_CPL_TITLE, app_title, ARRAY_SIZE(app_title));
|
|
|
|
LoadStringW(hInst, IDS_REMOVE, btnRemove, ARRAY_SIZE(btnRemove));
|
|
|
|
LoadStringW(hInst, IDS_MODIFY_REMOVE, btnModifyRemove, ARRAY_SIZE(btnModifyRemove));
|
2008-07-21 20:42:07 +02:00
|
|
|
|
|
|
|
/* Fill out the PROPSHEETPAGE */
|
|
|
|
psp.dwSize = sizeof (PROPSHEETPAGEW);
|
|
|
|
psp.dwFlags = PSP_USETITLE;
|
|
|
|
psp.hInstance = hInst;
|
2008-07-26 19:11:37 +02:00
|
|
|
psp.u.pszTemplate = MAKEINTRESOURCEW (IDD_MAIN);
|
|
|
|
psp.u2.pszIcon = NULL;
|
2012-11-19 09:28:43 +01:00
|
|
|
psp.pfnDlgProc = MainDlgProc;
|
2008-07-21 20:42:07 +02:00
|
|
|
psp.pszTitle = tab_title;
|
|
|
|
psp.lParam = 0;
|
|
|
|
|
|
|
|
/* Fill out the PROPSHEETHEADER */
|
|
|
|
psh.dwSize = sizeof (PROPSHEETHEADERW);
|
2010-04-16 16:24:28 +02:00
|
|
|
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK;
|
2008-07-21 20:42:07 +02:00
|
|
|
psh.hwndParent = hWnd;
|
|
|
|
psh.hInstance = hInst;
|
2010-04-16 16:24:28 +02:00
|
|
|
psh.u.pszIcon = MAKEINTRESOURCEW(ICO_MAIN);
|
2008-07-21 20:42:07 +02:00
|
|
|
psh.pszCaption = app_title;
|
|
|
|
psh.nPages = 1;
|
2008-07-26 19:11:37 +02:00
|
|
|
psh.u3.ppsp = &psp;
|
2010-04-16 16:24:28 +02:00
|
|
|
psh.pfnCallback = propsheet_callback;
|
2008-07-26 19:11:37 +02:00
|
|
|
psh.u2.nStartPage = 0;
|
2008-07-21 20:42:07 +02:00
|
|
|
|
|
|
|
/* Display the property sheet */
|
|
|
|
PropertySheetW (&psh);
|
|
|
|
}
|
|
|
|
|
2010-12-06 19:25:01 +01:00
|
|
|
static LONG start_params(const WCHAR *params)
|
|
|
|
{
|
2010-12-18 15:07:13 +01:00
|
|
|
if(!params)
|
|
|
|
return FALSE;
|
|
|
|
|
2020-11-01 23:31:58 +01:00
|
|
|
if(!wcscmp(params, L"install_gecko")) {
|
2012-05-15 11:48:31 +02:00
|
|
|
install_addon(ADDON_GECKO);
|
2010-12-06 19:25:01 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-11-01 23:31:58 +01:00
|
|
|
if(!wcscmp(params, L"install_mono")) {
|
2012-05-21 14:46:03 +02:00
|
|
|
install_addon(ADDON_MONO);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-12-06 19:25:01 +01:00
|
|
|
WARN("unknown param %s\n", debugstr_w(params));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-07-24 22:57:28 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Name : CPlApplet
|
|
|
|
* Description: Entry point for Control Panel applets
|
|
|
|
* Parameters : hwndCPL - hWnd of the Control Panel
|
|
|
|
* message - reason for calling function
|
|
|
|
* lParam1 - additional parameter
|
|
|
|
* lParam2 - additional parameter
|
2012-05-15 10:15:32 +02:00
|
|
|
* Returns : Depends on the message
|
2008-07-24 22:57:28 +02:00
|
|
|
*/
|
|
|
|
LONG CALLBACK CPlApplet(HWND hwndCPL, UINT message, LPARAM lParam1, LPARAM lParam2)
|
|
|
|
{
|
2008-07-21 20:42:07 +02:00
|
|
|
INITCOMMONCONTROLSEX iccEx;
|
|
|
|
|
2008-07-24 22:57:28 +02:00
|
|
|
switch (message)
|
|
|
|
{
|
|
|
|
case CPL_INIT:
|
2008-07-21 20:42:07 +02:00
|
|
|
iccEx.dwSize = sizeof(iccEx);
|
2011-12-01 20:37:18 +01:00
|
|
|
iccEx.dwICC = ICC_LISTVIEW_CLASSES | ICC_TAB_CLASSES | ICC_LINK_CLASS;
|
2008-07-21 20:42:07 +02:00
|
|
|
|
|
|
|
InitCommonControlsEx(&iccEx);
|
|
|
|
|
2008-07-24 22:57:28 +02:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case CPL_GETCOUNT:
|
|
|
|
return 1;
|
|
|
|
|
2010-12-06 19:25:01 +01:00
|
|
|
case CPL_STARTWPARMSW:
|
|
|
|
return start_params((const WCHAR *)lParam2);
|
|
|
|
|
2008-07-24 22:57:28 +02:00
|
|
|
case CPL_INQUIRE:
|
|
|
|
{
|
|
|
|
CPLINFO *appletInfo = (CPLINFO *) lParam2;
|
|
|
|
|
|
|
|
appletInfo->idIcon = ICO_MAIN;
|
|
|
|
appletInfo->idName = IDS_CPL_TITLE;
|
|
|
|
appletInfo->idInfo = IDS_CPL_DESC;
|
|
|
|
appletInfo->lData = 0;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2008-07-21 20:42:07 +02:00
|
|
|
|
|
|
|
case CPL_DBLCLK:
|
|
|
|
StartApplet(hwndCPL);
|
|
|
|
break;
|
2008-07-24 22:57:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|