2000-08-01 02:27:35 +02:00
|
|
|
/*
|
|
|
|
* Q&D Uninstaller (main.c)
|
2002-06-01 01:06:46 +02:00
|
|
|
*
|
2001-11-19 03:30:01 +01:00
|
|
|
* Copyright 2000 Andreas Mohr <andi@lisas.de>
|
2004-06-29 01:51:55 +02:00
|
|
|
* Copyright 2004 Hannu Valtonen <Hannu.Valtonen@hut.fi>
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2002-03-19 03:03:58 +01:00
|
|
|
*
|
|
|
|
* ToDo:
|
|
|
|
* - add search box for locating entries quickly
|
2000-08-01 02:27:35 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <windows.h>
|
|
|
|
#include "main.h"
|
|
|
|
#include "regstr.h"
|
2002-07-05 23:23:54 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(uninstaller);
|
2000-08-01 02:27:35 +02:00
|
|
|
|
|
|
|
/* Work around a Wine bug which defines handles as UINT rather than LPVOID */
|
|
|
|
#ifdef WINE_STRICT
|
|
|
|
#define NULL_HANDLE NULL
|
|
|
|
#else
|
|
|
|
#define NULL_HANDLE 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* use multi-select listbox */
|
|
|
|
#undef USE_MULTIPLESEL
|
|
|
|
|
|
|
|
/* Delete uninstall registry key after execution.
|
|
|
|
* This is probably a bad idea, because it's the
|
|
|
|
* uninstall program that is supposed to do that.
|
|
|
|
*/
|
|
|
|
#undef DEL_REG_KEY
|
|
|
|
|
|
|
|
char appname[18];
|
|
|
|
|
|
|
|
static char about_string[] =
|
2004-02-09 21:57:21 +01:00
|
|
|
"Wine Application Uninstaller (C) 2004 by Andreas Mohr <andi@lisas.de> and Hannu Valtonen <Hannu.Valtonen@hut.fi>";
|
2000-08-01 02:27:35 +02:00
|
|
|
static char program_description[] =
|
2004-02-09 21:57:21 +01:00
|
|
|
"Please select the application you wish to uninstall:";
|
2000-08-01 02:27:35 +02:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char *key;
|
2004-02-24 02:01:10 +01:00
|
|
|
WCHAR *descr;
|
2000-08-01 02:27:35 +02:00
|
|
|
char *command;
|
|
|
|
int active;
|
|
|
|
} uninst_entry;
|
|
|
|
|
|
|
|
uninst_entry *entries = NULL;
|
|
|
|
|
2004-09-22 04:46:38 +02:00
|
|
|
unsigned int numentries = 0;
|
2002-03-19 03:03:58 +01:00
|
|
|
int list_need_update = 1;
|
|
|
|
int oldsel = -1;
|
2000-08-01 02:27:35 +02:00
|
|
|
|
|
|
|
struct {
|
|
|
|
DWORD style;
|
|
|
|
LPCSTR text;
|
|
|
|
HWND hwnd;
|
|
|
|
} button[] =
|
|
|
|
{
|
|
|
|
{ BS_PUSHBUTTON, "Add/Remove", 0 },
|
|
|
|
{ BS_PUSHBUTTON, "About", 0 },
|
|
|
|
{ BS_PUSHBUTTON, "Exit", 0 }
|
|
|
|
};
|
|
|
|
|
2003-06-18 21:45:22 +02:00
|
|
|
#define NUM (sizeof(button)/sizeof(button[0]))
|
2000-08-01 02:27:35 +02:00
|
|
|
|
2002-03-19 03:03:58 +01:00
|
|
|
int FetchUninstallInformation(void);
|
2001-07-08 22:28:23 +02:00
|
|
|
void UninstallProgram(void);
|
|
|
|
|
|
|
|
void ListUninstallPrograms(void)
|
|
|
|
{
|
2004-09-22 04:46:38 +02:00
|
|
|
unsigned int i;
|
|
|
|
int len;
|
2004-02-24 02:01:10 +01:00
|
|
|
char *descr;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-03-19 03:03:58 +01:00
|
|
|
if (! FetchUninstallInformation())
|
2002-04-06 02:38:33 +02:00
|
|
|
return;
|
2001-07-08 22:28:23 +02:00
|
|
|
|
|
|
|
for (i=0; i < numentries; i++)
|
2004-02-24 02:01:10 +01:00
|
|
|
{
|
|
|
|
len = WideCharToMultiByte(CP_UNIXCP, 0, entries[i].descr, -1, NULL, 0, NULL, NULL);
|
|
|
|
descr = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
WideCharToMultiByte(CP_UNIXCP, 0, entries[i].descr, -1, descr, len, NULL, NULL);
|
|
|
|
printf("%s|||%s\n", entries[i].key, descr);
|
|
|
|
HeapFree(GetProcessHeap(), 0, descr);
|
|
|
|
}
|
2001-07-08 22:28:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void RemoveSpecificProgram(char *name)
|
|
|
|
{
|
2004-09-22 04:46:38 +02:00
|
|
|
unsigned int i;
|
2001-07-08 22:28:23 +02:00
|
|
|
|
2002-03-19 03:03:58 +01:00
|
|
|
if (! FetchUninstallInformation())
|
2002-04-06 02:38:33 +02:00
|
|
|
return;
|
2001-07-08 22:28:23 +02:00
|
|
|
|
|
|
|
for (i=0; i < numentries; i++)
|
|
|
|
{
|
|
|
|
if (strcmp(entries[i].key, name) == 0)
|
|
|
|
{
|
|
|
|
entries[i].active++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i < numentries)
|
|
|
|
UninstallProgram();
|
|
|
|
else
|
|
|
|
{
|
2004-02-09 21:57:21 +01:00
|
|
|
fprintf(stderr, "Error: could not match application [%s]\n", name);
|
2001-07-08 22:28:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-09 21:45:54 +02:00
|
|
|
int main( int argc, char *argv[])
|
2002-06-01 01:06:46 +02:00
|
|
|
{
|
2000-08-01 02:27:35 +02:00
|
|
|
MSG msg;
|
|
|
|
WNDCLASS wc;
|
|
|
|
HWND hWnd;
|
2003-10-09 21:45:54 +02:00
|
|
|
LPSTR token = NULL;
|
|
|
|
int i = 1;
|
|
|
|
HINSTANCE hInst = NULL;
|
2000-08-01 02:27:35 +02:00
|
|
|
|
2003-10-09 21:45:54 +02:00
|
|
|
while( i<argc )
|
2001-07-08 22:28:23 +02:00
|
|
|
{
|
2003-10-09 21:45:54 +02:00
|
|
|
token = argv[i++];
|
2001-07-08 22:28:23 +02:00
|
|
|
|
2004-02-09 21:57:21 +01:00
|
|
|
/* Handle requests just to list the applications */
|
2003-10-09 21:45:54 +02:00
|
|
|
if( !lstrcmpA( token, "--list" ) )
|
|
|
|
{
|
|
|
|
ListUninstallPrograms();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if( !lstrcmpA( token, "--remove" ) )
|
|
|
|
{
|
|
|
|
if( i >= argc )
|
|
|
|
{
|
|
|
|
WINE_ERR( "The remove option requires a parameter.\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
RemoveSpecificProgram( argv[i++] );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WINE_ERR( "unknown option %s\n",token);
|
|
|
|
return 1;
|
|
|
|
}
|
2001-07-08 22:28:23 +02:00
|
|
|
}
|
|
|
|
|
2000-08-01 02:27:35 +02:00
|
|
|
LoadString( hInst, IDS_APPNAME, appname, sizeof(appname));
|
|
|
|
|
|
|
|
wc.style = 0;
|
|
|
|
wc.lpfnWndProc = MainProc;
|
|
|
|
wc.cbClsExtra = 0;
|
|
|
|
wc.cbWndExtra = 0;
|
|
|
|
wc.hInstance = hInst;
|
|
|
|
wc.hIcon = LoadIcon( hInst, appname );
|
|
|
|
wc.hCursor = LoadCursor( NULL_HANDLE, IDI_APPLICATION );
|
2004-02-24 02:01:10 +01:00
|
|
|
wc.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
|
2000-08-01 02:27:35 +02:00
|
|
|
wc.lpszMenuName = NULL;
|
|
|
|
wc.lpszClassName = appname;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-08-01 02:27:35 +02:00
|
|
|
if (!RegisterClass(&wc)) exit(1);
|
2004-02-09 21:57:21 +01:00
|
|
|
hWnd = CreateWindow( appname, "Wine Application Uninstaller",
|
2002-06-01 01:06:46 +02:00
|
|
|
WS_OVERLAPPEDWINDOW & ~WS_THICKFRAME & ~WS_MAXIMIZEBOX,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
2000-08-01 02:27:35 +02:00
|
|
|
NULL_HANDLE, NULL_HANDLE, hInst, NULL );
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-08-01 02:27:35 +02:00
|
|
|
if (!hWnd) exit(1);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2003-10-09 21:45:54 +02:00
|
|
|
ShowWindow( hWnd, SW_SHOW );
|
2000-08-01 02:27:35 +02:00
|
|
|
UpdateWindow( hWnd );
|
|
|
|
|
|
|
|
while( GetMessage(&msg, NULL_HANDLE, 0, 0) ) {
|
|
|
|
TranslateMessage( &msg );
|
|
|
|
DispatchMessage( &msg );
|
|
|
|
}
|
|
|
|
return msg.wParam;
|
|
|
|
}
|
|
|
|
|
2002-03-19 03:03:58 +01:00
|
|
|
int cmp_by_name(const void *a, const void *b)
|
|
|
|
{
|
2004-11-30 22:38:57 +01:00
|
|
|
return lstrcmpiW(((const uninst_entry *)a)->descr, ((const uninst_entry *)b)->descr);
|
2002-03-19 03:03:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int FetchUninstallInformation(void)
|
2000-08-01 02:27:35 +02:00
|
|
|
{
|
|
|
|
HKEY hkeyUninst, hkeyApp;
|
|
|
|
int i;
|
2004-02-24 02:01:10 +01:00
|
|
|
DWORD sizeOfSubKeyName, displen, uninstlen;
|
2004-02-09 21:57:21 +01:00
|
|
|
char subKeyName[256];
|
2000-08-01 02:27:35 +02:00
|
|
|
char key_app[1024];
|
|
|
|
char *p;
|
|
|
|
|
2002-03-19 03:03:58 +01:00
|
|
|
numentries = 0;
|
|
|
|
oldsel = -1;
|
2004-02-24 02:01:10 +01:00
|
|
|
if ( RegOpenKeyExA(HKEY_LOCAL_MACHINE, REGSTR_PATH_UNINSTALL,
|
2000-08-01 02:27:35 +02:00
|
|
|
0, KEY_READ, &hkeyUninst) != ERROR_SUCCESS )
|
|
|
|
{
|
|
|
|
MessageBox(0, "Uninstall registry key not available (yet), nothing to do !", appname, MB_OK);
|
|
|
|
return 0;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2003-09-25 22:21:47 +02:00
|
|
|
if (!entries)
|
|
|
|
entries = HeapAlloc(GetProcessHeap(), 0, sizeof(uninst_entry));
|
|
|
|
|
2000-08-01 02:27:35 +02:00
|
|
|
strcpy(key_app, REGSTR_PATH_UNINSTALL);
|
|
|
|
strcat(key_app, "\\");
|
|
|
|
p = key_app+strlen(REGSTR_PATH_UNINSTALL)+1;
|
2004-02-24 02:01:10 +01:00
|
|
|
|
|
|
|
sizeOfSubKeyName = 255;
|
2000-08-01 02:27:35 +02:00
|
|
|
for ( i=0;
|
|
|
|
RegEnumKeyExA( hkeyUninst, i, subKeyName, &sizeOfSubKeyName,
|
|
|
|
NULL, NULL, NULL, NULL ) != ERROR_NO_MORE_ITEMS;
|
2004-02-24 02:01:10 +01:00
|
|
|
++i )
|
2000-08-01 02:27:35 +02:00
|
|
|
{
|
2004-02-24 02:01:10 +01:00
|
|
|
static const WCHAR DisplayNameW[] = {'D','i','s','p','l','a','y','N','a','m','e',0};
|
|
|
|
|
2000-08-01 02:27:35 +02:00
|
|
|
strcpy(p, subKeyName);
|
2004-02-24 02:01:10 +01:00
|
|
|
RegOpenKeyExA(HKEY_LOCAL_MACHINE, key_app, 0, KEY_READ, &hkeyApp);
|
2000-08-01 02:27:35 +02:00
|
|
|
|
2004-02-24 02:01:10 +01:00
|
|
|
if ( (RegQueryValueExW(hkeyApp, DisplayNameW,
|
2000-08-01 02:27:35 +02:00
|
|
|
0, 0, NULL, &displen) == ERROR_SUCCESS)
|
2004-02-24 02:01:10 +01:00
|
|
|
&& (RegQueryValueExA(hkeyApp, REGSTR_VAL_UNINSTALLER_COMMANDLINE,
|
2000-08-01 02:27:35 +02:00
|
|
|
0, 0, NULL, &uninstlen) == ERROR_SUCCESS) )
|
|
|
|
{
|
|
|
|
numentries++;
|
|
|
|
entries = HeapReAlloc(GetProcessHeap(), 0, entries, numentries*sizeof(uninst_entry));
|
|
|
|
entries[numentries-1].key =
|
|
|
|
HeapAlloc(GetProcessHeap(), 0, strlen(subKeyName)+1);
|
|
|
|
strcpy(entries[numentries-1].key, subKeyName);
|
|
|
|
entries[numentries-1].descr =
|
|
|
|
HeapAlloc(GetProcessHeap(), 0, displen);
|
2004-02-24 02:01:10 +01:00
|
|
|
RegQueryValueExW(hkeyApp, DisplayNameW, 0, 0,
|
|
|
|
(LPBYTE)entries[numentries-1].descr, &displen);
|
2000-08-01 02:27:35 +02:00
|
|
|
entries[numentries-1].command =
|
|
|
|
HeapAlloc(GetProcessHeap(), 0, uninstlen);
|
|
|
|
entries[numentries-1].active = 0;
|
2004-02-24 02:01:10 +01:00
|
|
|
RegQueryValueExA(hkeyApp, REGSTR_VAL_UNINSTALLER_COMMANDLINE, 0, 0,
|
2000-08-01 02:27:35 +02:00
|
|
|
entries[numentries-1].command, &uninstlen);
|
2004-02-24 02:01:10 +01:00
|
|
|
WINE_TRACE("allocated entry #%d: %s (%s), %s\n",
|
|
|
|
numentries, entries[numentries-1].key,
|
|
|
|
wine_dbgstr_w(entries[numentries-1].descr),
|
|
|
|
entries[numentries-1].command);
|
2000-08-01 02:27:35 +02:00
|
|
|
}
|
|
|
|
RegCloseKey(hkeyApp);
|
2004-02-24 02:01:10 +01:00
|
|
|
|
|
|
|
sizeOfSubKeyName = 255;
|
2000-08-01 02:27:35 +02:00
|
|
|
}
|
2002-03-19 03:03:58 +01:00
|
|
|
qsort(entries, numentries, sizeof(uninst_entry), cmp_by_name);
|
2000-08-01 02:27:35 +02:00
|
|
|
RegCloseKey(hkeyUninst);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2001-07-08 22:28:23 +02:00
|
|
|
void UninstallProgram(void)
|
2000-08-01 02:27:35 +02:00
|
|
|
{
|
2004-09-22 04:46:38 +02:00
|
|
|
unsigned int i;
|
2000-08-01 02:27:35 +02:00
|
|
|
char errormsg[1024];
|
|
|
|
BOOL res;
|
|
|
|
STARTUPINFO si;
|
|
|
|
PROCESS_INFORMATION info;
|
|
|
|
DWORD exit_code;
|
|
|
|
#ifdef DEL_REG_KEY
|
|
|
|
HKEY hkey;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for (i=0; i < numentries; i++)
|
|
|
|
{
|
|
|
|
if (!(entries[i].active)) /* don't uninstall this one */
|
|
|
|
continue;
|
2004-02-24 02:01:10 +01:00
|
|
|
WINE_TRACE("uninstalling %s\n", wine_dbgstr_w(entries[i].descr));
|
2000-08-01 02:27:35 +02:00
|
|
|
memset(&si, 0, sizeof(STARTUPINFO));
|
|
|
|
si.cb = sizeof(STARTUPINFO);
|
|
|
|
si.wShowWindow = SW_NORMAL;
|
|
|
|
res = CreateProcess(NULL, entries[i].command, NULL, NULL, FALSE, 0, NULL, NULL, &si, &info);
|
2004-12-09 15:07:59 +01:00
|
|
|
if (res)
|
2000-08-01 02:27:35 +02:00
|
|
|
{ /* wait for the process to exit */
|
|
|
|
WaitForSingleObject(info.hProcess, INFINITE);
|
|
|
|
res = GetExitCodeProcess(info.hProcess, &exit_code);
|
2002-07-05 23:23:54 +02:00
|
|
|
WINE_TRACE("%d: %08lx\n", res, exit_code);
|
2000-08-01 02:27:35 +02:00
|
|
|
#ifdef DEL_REG_KEY
|
2004-02-09 21:57:21 +01:00
|
|
|
/* delete the application's uninstall entry */
|
2000-08-01 02:27:35 +02:00
|
|
|
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, REGSTR_PATH_UNINSTALL,
|
|
|
|
0, KEY_READ, &hkey) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
RegDeleteKey(hkey, entries[i].key);
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sprintf(errormsg, "Execution of uninstall command '%s' failed, perhaps due to missing executable.", entries[i].command);
|
|
|
|
MessageBox(0, errormsg, appname, MB_OK);
|
|
|
|
}
|
|
|
|
}
|
2002-07-05 23:23:54 +02:00
|
|
|
WINE_TRACE("finished uninstall phase.\n");
|
2002-03-19 03:03:58 +01:00
|
|
|
list_need_update = 1;
|
2000-08-01 02:27:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT WINAPI MainProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2004-06-29 01:51:55 +02:00
|
|
|
HFONT static_font, listbox_font;
|
2000-08-01 02:27:35 +02:00
|
|
|
HDC hdc;
|
|
|
|
PAINTSTRUCT ps;
|
|
|
|
TEXTMETRIC tm;
|
2004-09-22 04:46:38 +02:00
|
|
|
unsigned int i;
|
|
|
|
int cxChar, cyChar, y, bx, maxx, maxy, wx, wy;
|
2004-06-29 01:51:55 +02:00
|
|
|
static HWND hwndList = 0, static_text = 0;
|
2000-08-01 02:27:35 +02:00
|
|
|
DWORD style;
|
|
|
|
RECT rect;
|
|
|
|
|
|
|
|
switch( msg ) {
|
|
|
|
case WM_CREATE:
|
|
|
|
{
|
|
|
|
hdc = GetDC(hWnd);
|
|
|
|
GetTextMetrics(hdc, &tm);
|
2004-06-29 01:51:55 +02:00
|
|
|
static_font = CreateFont(tm.tmHeight + tm.tmExternalLeading, 0, 0, 0, 600, FALSE, 0, 0, 0, 0, 0, 0, 0, "Times New Roman");
|
|
|
|
listbox_font = CreateFont(tm.tmHeight + tm.tmExternalLeading, 0, 0, 0, 0, TRUE, 0, 0, 0, 0, 0, 0, 0, "Times New Roman");
|
2000-08-01 02:27:35 +02:00
|
|
|
cxChar = tm.tmAveCharWidth;
|
|
|
|
cyChar = tm.tmHeight + tm.tmExternalLeading;
|
|
|
|
ReleaseDC(hWnd, hdc);
|
|
|
|
/* FIXME: implement sorting and use LBS_SORT here ! */
|
|
|
|
style = (WS_CHILD|WS_VISIBLE|LBS_STANDARD) & ~LBS_SORT;
|
|
|
|
#ifdef USE_MULTIPLESEL
|
|
|
|
style |= LBS_MULTIPLESEL;
|
|
|
|
#endif
|
2004-06-29 01:51:55 +02:00
|
|
|
bx = maxx = cxChar * 3;
|
2004-02-09 21:57:21 +01:00
|
|
|
y = maxy = cyChar * 1;
|
2004-06-29 01:51:55 +02:00
|
|
|
static_text = CreateWindow("static", program_description,
|
2004-02-09 21:57:21 +01:00
|
|
|
WS_CHILD|WS_VISIBLE|SS_LEFT,
|
|
|
|
maxx, maxy,
|
|
|
|
cxChar * sizeof(program_description), cyChar * 1,
|
|
|
|
hWnd, (HMENU)1,
|
|
|
|
((LPCREATESTRUCT)lParam)->hInstance, NULL);
|
2004-06-29 01:51:55 +02:00
|
|
|
SendMessage(static_text, WM_SETFONT, (WPARAM)static_font, MAKELPARAM(FALSE, 0));
|
2004-02-09 21:57:21 +01:00
|
|
|
maxy += cyChar * 2; /*static text + distance */
|
2000-08-01 02:27:35 +02:00
|
|
|
hwndList = CreateWindow("listbox", NULL,
|
|
|
|
style,
|
|
|
|
maxx, maxy,
|
2004-02-09 21:57:21 +01:00
|
|
|
cxChar * 50 + GetSystemMetrics(SM_CXVSCROLL), cyChar * 10,
|
2000-08-01 02:27:35 +02:00
|
|
|
hWnd, (HMENU) 1,
|
|
|
|
(HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE), NULL);
|
2004-06-29 01:51:55 +02:00
|
|
|
SendMessage(hwndList, WM_SETFONT, (WPARAM)listbox_font, MAKELPARAM(FALSE, 0));
|
2000-08-01 02:27:35 +02:00
|
|
|
GetWindowRect(hwndList, &rect);
|
2004-02-09 21:57:21 +01:00
|
|
|
maxx += (rect.right - rect.left)*1.1;
|
2000-08-01 02:27:35 +02:00
|
|
|
maxy += (rect.bottom - rect.top)*1.1;
|
|
|
|
wx = 20*cxChar;
|
|
|
|
wy = 7*cyChar/4;
|
2004-02-09 21:57:21 +01:00
|
|
|
y = cyChar * 3;
|
2000-08-01 02:27:35 +02:00
|
|
|
for (i=0; i < NUM; i++)
|
|
|
|
{
|
|
|
|
button[i].hwnd = CreateWindow("button", button[i].text,
|
|
|
|
WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,
|
|
|
|
maxx, y,
|
|
|
|
wx, wy,
|
|
|
|
hWnd, (HMENU)i,
|
|
|
|
((LPCREATESTRUCT)lParam)->hInstance, NULL);
|
|
|
|
if (!button[i].hwnd)
|
|
|
|
PostQuitMessage(0);
|
|
|
|
y += 2*cyChar;
|
|
|
|
}
|
2004-06-29 01:51:55 +02:00
|
|
|
maxx += wx + cxChar * 4;
|
|
|
|
maxy += cyChar * 2; /* window border */
|
2000-08-01 02:27:35 +02:00
|
|
|
SetWindowPos( hWnd, 0,
|
|
|
|
0, 0, maxx, maxy,
|
|
|
|
SWP_NOMOVE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
case WM_PAINT:
|
|
|
|
{
|
2002-07-05 23:23:54 +02:00
|
|
|
hdc = BeginPaint( hWnd, &ps );
|
2002-03-19 03:03:58 +01:00
|
|
|
if (list_need_update)
|
|
|
|
{
|
|
|
|
int prevsel;
|
|
|
|
prevsel = SendMessage(hwndList, LB_GETCURSEL, 0, 0);
|
|
|
|
if (!(FetchUninstallInformation()))
|
|
|
|
{
|
|
|
|
PostQuitMessage(0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
SendMessage(hwndList, LB_RESETCONTENT, 0, 0);
|
|
|
|
SendMessage(hwndList, WM_SETREDRAW, FALSE, 0);
|
|
|
|
for (i=0; i < numentries; i++)
|
|
|
|
{
|
2004-02-24 02:01:10 +01:00
|
|
|
WINE_TRACE("adding %s\n", wine_dbgstr_w(entries[i].descr));
|
|
|
|
SendMessageW(hwndList, LB_ADDSTRING, 0, (LPARAM)entries[i].descr);
|
2002-03-19 03:03:58 +01:00
|
|
|
}
|
2002-07-05 23:23:54 +02:00
|
|
|
WINE_TRACE("setting prevsel %d\n", prevsel);
|
2002-03-19 03:03:58 +01:00
|
|
|
if (prevsel != -1)
|
|
|
|
SendMessage(hwndList, LB_SETCURSEL, prevsel, 0 );
|
|
|
|
SendMessage(hwndList, WM_SETREDRAW, TRUE, 0);
|
|
|
|
list_need_update = 0;
|
|
|
|
}
|
2000-08-01 02:27:35 +02:00
|
|
|
EndPaint( hWnd, &ps );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
case WM_DESTROY:
|
|
|
|
PostQuitMessage( 0 );
|
|
|
|
return 0;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-08-01 02:27:35 +02:00
|
|
|
case WM_COMMAND:
|
|
|
|
if ((HWND)lParam == hwndList)
|
|
|
|
{
|
|
|
|
if (HIWORD(wParam) == LBN_SELCHANGE)
|
|
|
|
{
|
|
|
|
int sel = SendMessage(hwndList, LB_GETCURSEL, 0, 0);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-03-19 03:03:58 +01:00
|
|
|
#ifndef USE_MULTIPLESEL
|
|
|
|
if (oldsel != -1)
|
|
|
|
{
|
|
|
|
entries[oldsel].active ^= 1; /* toggle */
|
2004-02-24 02:01:10 +01:00
|
|
|
WINE_TRACE("toggling %d old %s\n", entries[oldsel].active,
|
|
|
|
wine_dbgstr_w(entries[oldsel].descr));
|
2002-03-19 03:03:58 +01:00
|
|
|
}
|
|
|
|
#endif
|
2000-08-01 02:27:35 +02:00
|
|
|
entries[sel].active ^= 1; /* toggle */
|
2004-02-24 02:01:10 +01:00
|
|
|
WINE_TRACE("toggling %d %s\n", entries[sel].active,
|
|
|
|
wine_dbgstr_w(entries[oldsel].descr));
|
2002-03-19 03:03:58 +01:00
|
|
|
oldsel = sel;
|
2000-08-01 02:27:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if ((HWND)lParam == button[0].hwnd) /* Uninstall button */
|
2001-07-08 22:28:23 +02:00
|
|
|
{
|
|
|
|
UninstallProgram();
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-07-08 22:28:23 +02:00
|
|
|
InvalidateRect(hWnd, NULL, TRUE);
|
|
|
|
UpdateWindow(hWnd);
|
|
|
|
|
|
|
|
}
|
2000-08-01 02:27:35 +02:00
|
|
|
else
|
|
|
|
if ((HWND)lParam == button[1].hwnd) /* About button */
|
2004-02-09 21:57:21 +01:00
|
|
|
MessageBox(0, about_string, "About Wine Application Uninstaller", MB_OK);
|
2000-08-01 02:27:35 +02:00
|
|
|
else
|
|
|
|
if ((HWND)lParam == button[2].hwnd) /* Exit button */
|
|
|
|
PostQuitMessage(0);
|
|
|
|
return 0;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-08-01 02:27:35 +02:00
|
|
|
return( DefWindowProc( hWnd, msg, wParam, lParam ));
|
|
|
|
}
|