Mercurial > vim
comparison src/uninstal.c @ 2475:7d1044b27eb5 vim73
Windows uninstaller: Instead of calling RegDeleteKeyEx() directly load it
dynamically from the .dll. Should work everywhere.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Mon, 02 Aug 2010 23:06:46 +0200 |
parents | b204ac54bea4 |
children | 6768ebd0bc04 |
comparison
equal
deleted
inserted
replaced
2474:a29301e7c05f | 2475:7d1044b27eb5 |
---|---|
31 fflush(stdout); | 31 fflush(stdout); |
32 return (scanf(" %c", answer) == 1 && toupper(answer[0]) == 'Y'); | 32 return (scanf(" %c", answer) == 1 && toupper(answer[0]) == 'Y'); |
33 } | 33 } |
34 | 34 |
35 #ifdef WIN3264 | 35 #ifdef WIN3264 |
36 | |
37 static int | |
38 reg_delete_key(HKEY hRootKey, const char *key) | |
39 { | |
40 static int did_load = FALSE; | |
41 static HANDLE advapi_lib = NULL; | |
42 static LONG (WINAPI *delete_key_ex)(HKEY, LPCTSTR, REGSAM, DWORD) = NULL; | |
43 | |
44 if (!did_load) | |
45 { | |
46 /* The RegDeleteKeyEx() function is only available on new systems. It | |
47 * is required for 64-bit registry access. For other systems fall | |
48 * back to RegDeleteKey(). */ | |
49 did_load = TRUE; | |
50 advapi_lib = LoadLibrary("ADVAPI32.DLL"); | |
51 if (advapi_lib != NULL) | |
52 delete_key_ex = (LONG (WINAPI *)(HKEY, LPCTSTR, REGSAM, DWORD))GetProcAddress(advapi_lib, "RegDeleteKeyExA"); | |
53 } | |
54 if (delete_key_ex != NULL) { | |
55 return (*delete_key_ex)(hRootKey, key, KEY_WOW64_64KEY, 0); | |
56 } | |
57 return RegDeleteKey(hRootKey, key); | |
58 } | |
59 | |
36 /* | 60 /* |
37 * Check if the popup menu entry exists and what gvim it refers to. | 61 * Check if the popup menu entry exists and what gvim it refers to. |
38 * Returns non-zero when it's found. | 62 * Returns non-zero when it's found. |
39 */ | 63 */ |
40 static int | 64 static int |
87 remove_popup(void) | 111 remove_popup(void) |
88 { | 112 { |
89 int fail = 0; | 113 int fail = 0; |
90 HKEY kh; | 114 HKEY kh; |
91 | 115 |
92 if (RegDeleteKeyEx(HKEY_CLASSES_ROOT, "CLSID\\{51EEE242-AD87-11d3-9C1E-0090278BBD99}\\InProcServer32", | 116 if (reg_delete_key(HKEY_CLASSES_ROOT, "CLSID\\{51EEE242-AD87-11d3-9C1E-0090278BBD99}\\InProcServer32") != ERROR_SUCCESS) |
93 KEY_WOW64_64KEY, 0) != ERROR_SUCCESS) | 117 ++fail; |
94 ++fail; | 118 if (reg_delete_key(HKEY_CLASSES_ROOT, "CLSID\\{51EEE242-AD87-11d3-9C1E-0090278BBD99}") != ERROR_SUCCESS) |
95 if (RegDeleteKeyEx(HKEY_CLASSES_ROOT, "CLSID\\{51EEE242-AD87-11d3-9C1E-0090278BBD99}", | 119 ++fail; |
96 KEY_WOW64_64KEY, 0) != ERROR_SUCCESS) | 120 if (reg_delete_key(HKEY_CLASSES_ROOT, "*\\shellex\\ContextMenuHandlers\\gvim") != ERROR_SUCCESS) |
97 ++fail; | |
98 if (RegDeleteKeyEx(HKEY_CLASSES_ROOT, "*\\shellex\\ContextMenuHandlers\\gvim", | |
99 KEY_WOW64_64KEY, 0) != ERROR_SUCCESS) | |
100 ++fail; | 121 ++fail; |
101 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved", 0, | 122 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved", 0, |
102 KEY_WOW64_64KEY | KEY_ALL_ACCESS, &kh) != ERROR_SUCCESS) | 123 KEY_WOW64_64KEY | KEY_ALL_ACCESS, &kh) != ERROR_SUCCESS) |
103 ++fail; | 124 ++fail; |
104 else | 125 else |
105 { | 126 { |
106 if (RegDeleteValue(kh, "{51EEE242-AD87-11d3-9C1E-0090278BBD99}") != ERROR_SUCCESS) | 127 if (RegDeleteValue(kh, "{51EEE242-AD87-11d3-9C1E-0090278BBD99}") != ERROR_SUCCESS) |
107 ++fail; | 128 ++fail; |
108 RegCloseKey(kh); | 129 RegCloseKey(kh); |
109 } | 130 } |
110 if (RegDeleteKeyEx(HKEY_LOCAL_MACHINE, "Software\\Vim\\Gvim", | 131 if (reg_delete_key(HKEY_LOCAL_MACHINE, "Software\\Vim\\Gvim") != ERROR_SUCCESS) |
111 KEY_WOW64_64KEY, 0) != ERROR_SUCCESS) | 132 ++fail; |
112 ++fail; | 133 if (reg_delete_key(HKEY_LOCAL_MACHINE, "Software\\Vim") != ERROR_SUCCESS) |
113 if (RegDeleteKeyEx(HKEY_LOCAL_MACHINE, "Software\\Vim", | |
114 KEY_WOW64_64KEY, 0) != ERROR_SUCCESS) | |
115 ++fail; | 134 ++fail; |
116 | 135 |
117 if (fail == 6) | 136 if (fail == 6) |
118 printf("No Vim popup registry entries could be removed\n"); | 137 printf("No Vim popup registry entries could be removed\n"); |
119 else if (fail > 0) | 138 else if (fail > 0) |
125 static void | 144 static void |
126 remove_openwith(void) | 145 remove_openwith(void) |
127 { | 146 { |
128 int fail = 0; | 147 int fail = 0; |
129 | 148 |
130 if (RegDeleteKeyEx(HKEY_CLASSES_ROOT, "Applications\\gvim.exe\\shell\\edit\\command", | 149 if (reg_delete_key(HKEY_CLASSES_ROOT, "Applications\\gvim.exe\\shell\\edit\\command") != ERROR_SUCCESS) |
131 KEY_WOW64_64KEY, 0) != ERROR_SUCCESS) | 150 ++fail; |
132 ++fail; | 151 if (reg_delete_key(HKEY_CLASSES_ROOT, "Applications\\gvim.exe\\shell\\edit") != ERROR_SUCCESS) |
133 if (RegDeleteKeyEx(HKEY_CLASSES_ROOT, "Applications\\gvim.exe\\shell\\edit", | 152 ++fail; |
134 KEY_WOW64_64KEY, 0) != ERROR_SUCCESS) | 153 if (reg_delete_key(HKEY_CLASSES_ROOT, "Applications\\gvim.exe\\shell") != ERROR_SUCCESS) |
135 ++fail; | 154 ++fail; |
136 if (RegDeleteKeyEx(HKEY_CLASSES_ROOT, "Applications\\gvim.exe\\shell", | 155 if (reg_delete_key(HKEY_CLASSES_ROOT, "Applications\\gvim.exe") != ERROR_SUCCESS) |
137 KEY_WOW64_64KEY, 0) != ERROR_SUCCESS) | 156 ++fail; |
138 ++fail; | 157 if (reg_delete_key(HKEY_CLASSES_ROOT, ".htm\\OpenWithList\\gvim.exe") != ERROR_SUCCESS) |
139 if (RegDeleteKeyEx(HKEY_CLASSES_ROOT, "Applications\\gvim.exe", | 158 ++fail; |
140 KEY_WOW64_64KEY, 0) != ERROR_SUCCESS) | 159 if (reg_delete_key(HKEY_CLASSES_ROOT, ".vim\\OpenWithList\\gvim.exe") != ERROR_SUCCESS) |
141 ++fail; | 160 ++fail; |
142 if (RegDeleteKeyEx(HKEY_CLASSES_ROOT, ".htm\\OpenWithList\\gvim.exe", | 161 if (reg_delete_key(HKEY_CLASSES_ROOT, "*\\OpenWithList\\gvim.exe") != ERROR_SUCCESS) |
143 KEY_WOW64_64KEY, 0) != ERROR_SUCCESS) | |
144 ++fail; | |
145 if (RegDeleteKeyEx(HKEY_CLASSES_ROOT, ".vim\\OpenWithList\\gvim.exe", | |
146 KEY_WOW64_64KEY, 0) != ERROR_SUCCESS) | |
147 ++fail; | |
148 if (RegDeleteKeyEx(HKEY_CLASSES_ROOT, "*\\OpenWithList\\gvim.exe", | |
149 KEY_WOW64_64KEY, 0) != ERROR_SUCCESS) | |
150 ++fail; | 162 ++fail; |
151 | 163 |
152 if (fail == 7) | 164 if (fail == 7) |
153 printf("No Vim open-with registry entries could be removed\n"); | 165 printf("No Vim open-with registry entries could be removed\n"); |
154 else if (fail > 0) | 166 else if (fail > 0) |
300 | 312 |
301 static void | 313 static void |
302 delete_uninstall_key(void) | 314 delete_uninstall_key(void) |
303 { | 315 { |
304 #ifdef WIN3264 | 316 #ifdef WIN3264 |
305 RegDeleteKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Vim " VIM_VERSION_SHORT, | 317 reg_delete_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Vim " VIM_VERSION_SHORT); |
306 KEY_WOW64_64KEY, 0); | |
307 #else | 318 #else |
308 FILE *fd; | 319 FILE *fd; |
309 char buf[BUFSIZE]; | 320 char buf[BUFSIZE]; |
310 | 321 |
311 /* | 322 /* |