annotate src/uninstall.c @ 33385:b5ad84fdc702 v9.0.1951

patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI Commit: https://github.com/vim/vim/commit/b90e3bc491c02bd6e4db1a1c1849ce3d21811c43 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Thu Sep 28 23:06:48 2023 +0200 patch 9.0.1951: Vim9: hard to debug vim9_class errors from CI Problem: Vim9: hard to debug vim9_class errors from CI Solution: Include the line number in assert_xxx() calls. Include the entire error message in the tests. Fix the indentation in the test file. Add tags for new error codes. closes: #13206 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
author Christian Brabandt <cb@256bit.org>
date Thu, 28 Sep 2023 23:30:03 +0200
parents 1009c33499e7
children 1629cc65d78d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10042
4aead6a9b7a9 commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents: 8212
diff changeset
1 /* vi:set ts=8 sts=4 sw=4 noet:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 /*
18174
1ec6539cef68 patch 8.1.2082: some files have a weird name to fit in 8.3 characters
Bram Moolenaar <Bram@vim.org>
parents: 15941
diff changeset
11 * uninstall.c: Minimalistic uninstall program for Vim on MS-Windows
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 * Removes:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 * - the "Edit with Vim" popup menu entry
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 * - the Vim "Open With..." popup menu entry
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 * - any Vim Batch files in the path
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 * - icons for Vim on the Desktop
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 * - the Vim entry in the Start Menu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
20 // Include common code for dosinst.c and uninstall.c.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 #include "dosinst.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 * Return TRUE if the user types a 'y' or 'Y', FALSE otherwise.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 confirm(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 char answer[10];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 fflush(stdout);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 return (scanf(" %c", answer) == 1 && toupper(answer[0]) == 'Y');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34
2475
7d1044b27eb5 Windows uninstaller: Instead of calling RegDeleteKeyEx() directly load it
Bram Moolenaar <bram@vim.org>
parents: 2466
diff changeset
35 static int
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
36 reg_delete_key(HKEY hRootKey, const char *key, DWORD flag)
2475
7d1044b27eb5 Windows uninstaller: Instead of calling RegDeleteKeyEx() directly load it
Bram Moolenaar <bram@vim.org>
parents: 2466
diff changeset
37 {
7d1044b27eb5 Windows uninstaller: Instead of calling RegDeleteKeyEx() directly load it
Bram Moolenaar <bram@vim.org>
parents: 2466
diff changeset
38 static int did_load = FALSE;
7d1044b27eb5 Windows uninstaller: Instead of calling RegDeleteKeyEx() directly load it
Bram Moolenaar <bram@vim.org>
parents: 2466
diff changeset
39 static HANDLE advapi_lib = NULL;
7d1044b27eb5 Windows uninstaller: Instead of calling RegDeleteKeyEx() directly load it
Bram Moolenaar <bram@vim.org>
parents: 2466
diff changeset
40 static LONG (WINAPI *delete_key_ex)(HKEY, LPCTSTR, REGSAM, DWORD) = NULL;
7d1044b27eb5 Windows uninstaller: Instead of calling RegDeleteKeyEx() directly load it
Bram Moolenaar <bram@vim.org>
parents: 2466
diff changeset
41
7d1044b27eb5 Windows uninstaller: Instead of calling RegDeleteKeyEx() directly load it
Bram Moolenaar <bram@vim.org>
parents: 2466
diff changeset
42 if (!did_load)
7d1044b27eb5 Windows uninstaller: Instead of calling RegDeleteKeyEx() directly load it
Bram Moolenaar <bram@vim.org>
parents: 2466
diff changeset
43 {
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
44 // The RegDeleteKeyEx() function is only available on new systems. It
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
45 // is required for 64-bit registry access. For other systems fall
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
46 // back to RegDeleteKey().
2475
7d1044b27eb5 Windows uninstaller: Instead of calling RegDeleteKeyEx() directly load it
Bram Moolenaar <bram@vim.org>
parents: 2466
diff changeset
47 did_load = TRUE;
7d1044b27eb5 Windows uninstaller: Instead of calling RegDeleteKeyEx() directly load it
Bram Moolenaar <bram@vim.org>
parents: 2466
diff changeset
48 advapi_lib = LoadLibrary("ADVAPI32.DLL");
7d1044b27eb5 Windows uninstaller: Instead of calling RegDeleteKeyEx() directly load it
Bram Moolenaar <bram@vim.org>
parents: 2466
diff changeset
49 if (advapi_lib != NULL)
7d1044b27eb5 Windows uninstaller: Instead of calling RegDeleteKeyEx() directly load it
Bram Moolenaar <bram@vim.org>
parents: 2466
diff changeset
50 delete_key_ex = (LONG (WINAPI *)(HKEY, LPCTSTR, REGSAM, DWORD))GetProcAddress(advapi_lib, "RegDeleteKeyExA");
7d1044b27eb5 Windows uninstaller: Instead of calling RegDeleteKeyEx() directly load it
Bram Moolenaar <bram@vim.org>
parents: 2466
diff changeset
51 }
31804
50555279168b patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents: 19431
diff changeset
52 if (delete_key_ex != NULL)
50555279168b patch 9.0.1234: the code style has to be checked manually
Bram Moolenaar <Bram@vim.org>
parents: 19431
diff changeset
53 {
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
54 return (*delete_key_ex)(hRootKey, key, flag, 0);
2475
7d1044b27eb5 Windows uninstaller: Instead of calling RegDeleteKeyEx() directly load it
Bram Moolenaar <bram@vim.org>
parents: 2466
diff changeset
55 }
7d1044b27eb5 Windows uninstaller: Instead of calling RegDeleteKeyEx() directly load it
Bram Moolenaar <bram@vim.org>
parents: 2466
diff changeset
56 return RegDeleteKey(hRootKey, key);
7d1044b27eb5 Windows uninstaller: Instead of calling RegDeleteKeyEx() directly load it
Bram Moolenaar <bram@vim.org>
parents: 2466
diff changeset
57 }
7d1044b27eb5 Windows uninstaller: Instead of calling RegDeleteKeyEx() directly load it
Bram Moolenaar <bram@vim.org>
parents: 2466
diff changeset
58
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 * Check if the popup menu entry exists and what gvim it refers to.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 * Returns non-zero when it's found.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 static int
15941
b9098585d945 patch 8.1.0976: dosinstall still has buffer overflow problems
Bram Moolenaar <Bram@vim.org>
parents: 15892
diff changeset
64 popup_gvim_path(char *buf, DWORD bufsize)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 HKEY key_handle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 DWORD value_type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 int r;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
70 // Open the key where the path to gvim.exe is stored.
2449
943280505f72 Fix that uninstaller isn't found on 64-bit Windows.
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
71 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Vim\\Gvim", 0,
943280505f72 Fix that uninstaller isn't found on 64-bit Windows.
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
72 KEY_WOW64_64KEY | KEY_READ, &key_handle) != ERROR_SUCCESS)
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
73 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Vim\\Gvim", 0,
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
74 KEY_WOW64_32KEY | KEY_READ, &key_handle) != ERROR_SUCCESS)
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
75 return 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
77 // get the DisplayName out of it to show the user
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 r = RegQueryValueEx(key_handle, "path", 0,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 &value_type, (LPBYTE)buf, &bufsize);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 RegCloseKey(key_handle);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 return (r == ERROR_SUCCESS);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 * Check if the "Open With..." menu entry exists and what gvim it refers to.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 * Returns non-zero when it's found.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 static int
15941
b9098585d945 patch 8.1.0976: dosinstall still has buffer overflow problems
Bram Moolenaar <Bram@vim.org>
parents: 15892
diff changeset
90 openwith_gvim_path(char *buf, DWORD bufsize)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 HKEY key_handle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 DWORD value_type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 int r;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
96 // Open the key where the path to gvim.exe is stored.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 if (RegOpenKeyEx(HKEY_CLASSES_ROOT,
2449
943280505f72 Fix that uninstaller isn't found on 64-bit Windows.
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
98 "Applications\\gvim.exe\\shell\\edit\\command", 0,
943280505f72 Fix that uninstaller isn't found on 64-bit Windows.
Bram Moolenaar <bram@vim.org>
parents: 2287
diff changeset
99 KEY_WOW64_64KEY | KEY_READ, &key_handle) != ERROR_SUCCESS)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
102 // get the DisplayName out of it to show the user
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 r = RegQueryValueEx(key_handle, "", 0, &value_type, (LPBYTE)buf, &bufsize);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 RegCloseKey(key_handle);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 return (r == ERROR_SUCCESS);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 remove_popup(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 int fail = 0;
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
113 int i;
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
114 int loop = is_64bit_os() ? 2 : 1;
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
115 int maxfail = loop * 6;
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
116 DWORD flag;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 HKEY kh;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
119 for (i = 0; i < loop; i++)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 {
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
121 if (i == 0)
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
122 flag = KEY_WOW64_32KEY;
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
123 else
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
124 flag = KEY_WOW64_64KEY;
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
125
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
126 if (reg_delete_key(HKEY_CLASSES_ROOT, "CLSID\\{51EEE242-AD87-11d3-9C1E-0090278BBD99}\\InProcServer32", flag) != ERROR_SUCCESS)
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
127 ++fail;
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
128 if (reg_delete_key(HKEY_CLASSES_ROOT, "CLSID\\{51EEE242-AD87-11d3-9C1E-0090278BBD99}", flag) != ERROR_SUCCESS)
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
129 ++fail;
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
130 if (reg_delete_key(HKEY_CLASSES_ROOT, "*\\shellex\\ContextMenuHandlers\\gvim", flag) != ERROR_SUCCESS)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 ++fail;
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
132 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved", 0,
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
133 flag | KEY_ALL_ACCESS, &kh) != ERROR_SUCCESS)
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
134 ++fail;
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
135 else
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
136 {
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
137 if (RegDeleteValue(kh, "{51EEE242-AD87-11d3-9C1E-0090278BBD99}") != ERROR_SUCCESS)
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
138 ++fail;
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
139 RegCloseKey(kh);
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
140 }
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
141 if (reg_delete_key(HKEY_LOCAL_MACHINE, "Software\\Vim\\Gvim", flag) != ERROR_SUCCESS)
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
142 ++fail;
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
143 if (reg_delete_key(HKEY_LOCAL_MACHINE, "Software\\Vim", flag) != ERROR_SUCCESS)
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
144 ++fail;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
147 if (fail == maxfail)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 printf("No Vim popup registry entries could be removed\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 else if (fail > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 printf("Some Vim popup registry entries could not be removed\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 printf("The Vim popup registry entries have been removed\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 remove_openwith(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 int fail = 0;
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
159 int i;
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
160 int loop = is_64bit_os() ? 2 : 1;
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
161 int maxfail = loop * 7;
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
162 DWORD flag;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
164 for (i = 0; i < loop; i++)
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
165 {
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
166 if (i == 0)
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
167 flag = KEY_WOW64_32KEY;
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
168 else
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
169 flag = KEY_WOW64_64KEY;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
171 if (reg_delete_key(HKEY_CLASSES_ROOT, "Applications\\gvim.exe\\shell\\edit\\command", flag) != ERROR_SUCCESS)
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
172 ++fail;
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
173 if (reg_delete_key(HKEY_CLASSES_ROOT, "Applications\\gvim.exe\\shell\\edit", flag) != ERROR_SUCCESS)
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
174 ++fail;
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
175 if (reg_delete_key(HKEY_CLASSES_ROOT, "Applications\\gvim.exe\\shell", flag) != ERROR_SUCCESS)
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
176 ++fail;
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
177 if (reg_delete_key(HKEY_CLASSES_ROOT, "Applications\\gvim.exe", flag) != ERROR_SUCCESS)
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
178 ++fail;
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
179 if (reg_delete_key(HKEY_CLASSES_ROOT, ".htm\\OpenWithList\\gvim.exe", flag) != ERROR_SUCCESS)
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
180 ++fail;
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
181 if (reg_delete_key(HKEY_CLASSES_ROOT, ".vim\\OpenWithList\\gvim.exe", flag) != ERROR_SUCCESS)
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
182 ++fail;
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
183 if (reg_delete_key(HKEY_CLASSES_ROOT, "*\\OpenWithList\\gvim.exe", flag) != ERROR_SUCCESS)
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
184 ++fail;
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
185 }
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
186
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
187 if (fail == maxfail)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 printf("No Vim open-with registry entries could be removed\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 else if (fail > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 printf("Some Vim open-with registry entries could not be removed\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 printf("The Vim open-with registry entries have been removed\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 * Check if a batch file is really for the current version. Don't delete a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 * batch file that was written for another (possibly newer) version.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 batfile_thisversion(char *path)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 FILE *fd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 char line[BUFSIZE];
19431
9800e126eaa2 patch 8.2.0273: MS-Windows uninstall may delete wrong batch file
Bram Moolenaar <Bram@vim.org>
parents: 19356
diff changeset
204 int key_len = strlen(VIMBAT_UNINSTKEY);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 int found = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 fd = fopen(path, "r");
31827
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31804
diff changeset
208 if (fd == NULL)
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31804
diff changeset
209 return FALSE;
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31804
diff changeset
210
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31804
diff changeset
211 while (fgets(line, sizeof(line), fd) != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 {
31827
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31804
diff changeset
213 if (strncmp(line, VIMBAT_UNINSTKEY, key_len) == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 {
31827
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31804
diff changeset
215 found = TRUE;
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31804
diff changeset
216 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218 }
31827
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31804
diff changeset
219 fclose(fd);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 return found;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 remove_batfiles(int doit)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 char *batfile_path;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 int found = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229
19356
f559be3c53d7 patch 8.2.0236: MS-Windows unintall doesn't delete vimtutur.bat
Bram Moolenaar <Bram@vim.org>
parents: 18816
diff changeset
230 // avoid looking in the "installdir" by chdir to system root
f559be3c53d7 patch 8.2.0236: MS-Windows unintall doesn't delete vimtutur.bat
Bram Moolenaar <Bram@vim.org>
parents: 18816
diff changeset
231 mch_chdir(sysdrive);
f559be3c53d7 patch 8.2.0236: MS-Windows unintall doesn't delete vimtutur.bat
Bram Moolenaar <Bram@vim.org>
parents: 18816
diff changeset
232 mch_chdir("\\");
f559be3c53d7 patch 8.2.0236: MS-Windows unintall doesn't delete vimtutur.bat
Bram Moolenaar <Bram@vim.org>
parents: 18816
diff changeset
233
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 for (i = 1; i < TARGET_COUNT; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 batfile_path = searchpath_save(targets[i].batname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 if (batfile_path != NULL && batfile_thisversion(batfile_path))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 ++found;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 if (doit)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 printf("removing %s\n", batfile_path);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 remove(batfile_path);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 printf(" - the batch file %s\n", batfile_path);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 free(batfile_path);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 }
19356
f559be3c53d7 patch 8.2.0236: MS-Windows unintall doesn't delete vimtutur.bat
Bram Moolenaar <Bram@vim.org>
parents: 18816
diff changeset
250
f559be3c53d7 patch 8.2.0236: MS-Windows unintall doesn't delete vimtutur.bat
Bram Moolenaar <Bram@vim.org>
parents: 18816
diff changeset
251 mch_chdir(installdir);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 return found;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 remove_if_exists(char *path, char *filename)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 char buf[BUFSIZE];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259 FILE *fd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 sprintf(buf, "%s\\%s", path, filename);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263 fd = fopen(buf, "r");
31827
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31804
diff changeset
264 if (fd == NULL)
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31804
diff changeset
265 return;
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31804
diff changeset
266
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31804
diff changeset
267 fclose(fd);
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31804
diff changeset
268 printf("removing %s\n", buf);
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31804
diff changeset
269 remove(buf);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273 remove_icons(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
275 char path[BUFSIZE];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278 if (get_shell_folder_path(path, "desktop"))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279 for (i = 0; i < ICON_COUNT; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280 remove_if_exists(path, icon_link_names[i]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284 remove_start_menu(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286 char path[BUFSIZE];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288 struct stat st;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289
31827
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31804
diff changeset
290 if (get_shell_folder_path(path, VIM_STARTMENU) == FAIL)
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31804
diff changeset
291 return;
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31804
diff changeset
292
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31804
diff changeset
293 for (i = 1; i < TARGET_COUNT; ++i)
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31804
diff changeset
294 remove_if_exists(path, targets[i].lnkname);
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31804
diff changeset
295 remove_if_exists(path, "uninstall.lnk");
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31804
diff changeset
296 remove_if_exists(path, "Help.lnk");
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31804
diff changeset
297 // Win95 uses .pif, WinNT uses .lnk
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31804
diff changeset
298 remove_if_exists(path, "Vim tutor.pif");
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31804
diff changeset
299 remove_if_exists(path, "Vim tutor.lnk");
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31804
diff changeset
300 remove_if_exists(path, "Vim online.url");
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31804
diff changeset
301 if (stat(path, &st) == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302 {
31827
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31804
diff changeset
303 printf("removing %s\n", path);
1009c33499e7 patch 9.0.1246: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31804
diff changeset
304 rmdir(path);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
305 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
306 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309 delete_uninstall_key(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
310 {
12626
aca41efd888c patch 8.0.1191: MS-Windows: missing 32 and 64 bit files in installer
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
311 reg_delete_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Vim " VIM_VERSION_SHORT, KEY_WOW64_64KEY);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
313
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315 main(int argc, char *argv[])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
316 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
317 int found = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
318 FILE *fd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
319 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
320 struct stat st;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
321 char icon[BUFSIZE];
15892
e43b5e6d9190 patch 8.1.0952: compilation warnings when building the MS-Windows installer
Bram Moolenaar <Bram@vim.org>
parents: 12626
diff changeset
322 char path[MAX_PATH];
e43b5e6d9190 patch 8.1.0952: compilation warnings when building the MS-Windows installer
Bram Moolenaar <Bram@vim.org>
parents: 12626
diff changeset
323 char popup_path[MAX_PATH];
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
325 // The nsis uninstaller calls us with a "-nsis" argument.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
326 if (argc == 2 && stricmp(argv[1], "-nsis") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
327 interactive = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329 interactive = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
330
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
331 // Initialize this program.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
332 do_inits(argv);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
333
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
334 printf("This program will remove the following items:\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335
15941
b9098585d945 patch 8.1.0976: dosinstall still has buffer overflow problems
Bram Moolenaar <Bram@vim.org>
parents: 15892
diff changeset
336 if (popup_gvim_path(popup_path, sizeof(popup_path)))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
338 printf(" - the \"Edit with Vim\" entry in the popup menu\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339 printf(" which uses \"%s\"\n", popup_path);
2217
120502692d82 Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents: 7
diff changeset
340 if (interactive)
120502692d82 Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents: 7
diff changeset
341 printf("\nRemove it (y/n)? ");
120502692d82 Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents: 7
diff changeset
342 if (!interactive || confirm())
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
343 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344 remove_popup();
18816
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
345 // Assume the "Open With" entry can be removed as well, don't
15539899a112 patch 8.1.2396: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18174
diff changeset
346 // bother the user with asking him again.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347 remove_openwith();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349 }
15941
b9098585d945 patch 8.1.0976: dosinstall still has buffer overflow problems
Bram Moolenaar <Bram@vim.org>
parents: 15892
diff changeset
350 else if (openwith_gvim_path(popup_path, sizeof(popup_path)))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 printf(" - the Vim \"Open With...\" entry in the popup menu\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 printf(" which uses \"%s\"\n", popup_path);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 printf("\nRemove it (y/n)? ");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355 if (confirm())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356 remove_openwith();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359 if (get_shell_folder_path(path, "desktop"))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 printf("\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362 for (i = 0; i < ICON_COUNT; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
363 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364 sprintf(icon, "%s\\%s", path, icon_link_names[i]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365 if (stat(icon, &st) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367 printf(" - the \"%s\" icon on the desktop\n", icon_names[i]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368 ++found;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
370 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371 if (found > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373 if (interactive)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374 printf("\nRemove %s (y/n)? ", found > 1 ? "them" : "it");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375 if (!interactive || confirm())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 remove_icons();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380 if (get_shell_folder_path(path, VIM_STARTMENU)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381 && stat(path, &st) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
382 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
383 printf("\n - the \"%s\" entry in the Start Menu\n", VIM_STARTMENU);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
384 if (interactive)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
385 printf("\nRemove it (y/n)? ");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
386 if (!interactive || confirm())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387 remove_start_menu();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390 printf("\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391 found = remove_batfiles(0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 if (found > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394 if (interactive)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395 printf("\nRemove %s (y/n)? ", found > 1 ? "them" : "it");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396 if (!interactive || confirm())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397 remove_batfiles(1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400 fd = fopen("gvim.exe", "r");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401 if (fd != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
402 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403 fclose(fd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404 printf("gvim.exe detected. Attempting to unregister gvim with OLE\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405 system("gvim.exe -silent -unregister");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
408 delete_uninstall_key();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
409
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410 if (interactive)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
411 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
412 printf("\nYou may now want to delete the Vim executables and runtime files.\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
413 printf("(They are still where you unpacked them.)\n");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
414 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
415
2217
120502692d82 Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents: 7
diff changeset
416 if (interactive)
120502692d82 Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents: 7
diff changeset
417 {
120502692d82 Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents: 7
diff changeset
418 rewind(stdin);
120502692d82 Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents: 7
diff changeset
419 printf("\nPress Enter to exit...");
120502692d82 Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents: 7
diff changeset
420 (void)getchar();
120502692d82 Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents: 7
diff changeset
421 }
120502692d82 Improve the MS-Windows installer.
Bram Moolenaar <bram@vim.org>
parents: 7
diff changeset
422 else
2287
573da4dac306 Make the dos installer work with more compilers.
Bram Moolenaar <bram@vim.org>
parents: 2217
diff changeset
423 sleep(3);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
424
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
425 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
426 }