Browse files

Windows uninstaller: Instead of calling RegDeleteKeyEx() directly loa…

…d it

dynamically from the .dll.  Should work everywhere.

--HG--
branch : vim73
  • Loading branch information...
1 parent 1e68b02 commit 315cc1108f10d79807578ae83ba45ab07ab1aa92 @brammool brammool committed Aug 2, 2010
Showing with 41 additions and 27 deletions.
  1. +4 −0 runtime/doc/todo.txt
  2. +0 −1 src/dosinst.h
  3. +37 −26 src/uninstal.c
View
4 runtime/doc/todo.txt
@@ -33,6 +33,10 @@ be worked on, but only if you sponsor Vim development. See |sponsor|.
Using uninitialized memory when crypting an empty file. (Dominique Pelle, 2010
Aug 2)
+Go back to MSVC 2008, so that Windows 2000 is supported?
+
+For 'undoreload': put the cursor on the first line that is different.
+
Before release 7.3:
- Rename vim73 branch to default (hints: Xavier de Gaye, 2010 May 23)
View
1 src/dosinst.h
@@ -89,7 +89,6 @@ char *searchpath(char *name);
*/
# ifndef KEY_WOW64_64KEY
# define KEY_WOW64_64KEY 0x0100
-# define RegDeleteKeyEx(a, b, c, d) RegDeleteKey(a, b)
# endif
#define VIM_STARTMENU "Programs\\Vim " VIM_VERSION_SHORT
View
63 src/uninstal.c
@@ -33,6 +33,30 @@ confirm(void)
}
#ifdef WIN3264
+
+ static int
+reg_delete_key(HKEY hRootKey, const char *key)
+{
+ static int did_load = FALSE;
+ static HANDLE advapi_lib = NULL;
+ static LONG (WINAPI *delete_key_ex)(HKEY, LPCTSTR, REGSAM, DWORD) = NULL;
+
+ if (!did_load)
+ {
+ /* The RegDeleteKeyEx() function is only available on new systems. It
+ * is required for 64-bit registry access. For other systems fall
+ * back to RegDeleteKey(). */
+ did_load = TRUE;
+ advapi_lib = LoadLibrary("ADVAPI32.DLL");
+ if (advapi_lib != NULL)
+ delete_key_ex = (LONG (WINAPI *)(HKEY, LPCTSTR, REGSAM, DWORD))GetProcAddress(advapi_lib, "RegDeleteKeyExA");
+ }
+ if (delete_key_ex != NULL) {
+ return (*delete_key_ex)(hRootKey, key, KEY_WOW64_64KEY, 0);
+ }
+ return RegDeleteKey(hRootKey, key);
+}
+
/*
* Check if the popup menu entry exists and what gvim it refers to.
* Returns non-zero when it's found.
@@ -89,14 +113,11 @@ remove_popup(void)
int fail = 0;
HKEY kh;
- if (RegDeleteKeyEx(HKEY_CLASSES_ROOT, "CLSID\\{51EEE242-AD87-11d3-9C1E-0090278BBD99}\\InProcServer32",
- KEY_WOW64_64KEY, 0) != ERROR_SUCCESS)
+ if (reg_delete_key(HKEY_CLASSES_ROOT, "CLSID\\{51EEE242-AD87-11d3-9C1E-0090278BBD99}\\InProcServer32") != ERROR_SUCCESS)
++fail;
- if (RegDeleteKeyEx(HKEY_CLASSES_ROOT, "CLSID\\{51EEE242-AD87-11d3-9C1E-0090278BBD99}",
- KEY_WOW64_64KEY, 0) != ERROR_SUCCESS)
+ if (reg_delete_key(HKEY_CLASSES_ROOT, "CLSID\\{51EEE242-AD87-11d3-9C1E-0090278BBD99}") != ERROR_SUCCESS)
++fail;
- if (RegDeleteKeyEx(HKEY_CLASSES_ROOT, "*\\shellex\\ContextMenuHandlers\\gvim",
- KEY_WOW64_64KEY, 0) != ERROR_SUCCESS)
+ if (reg_delete_key(HKEY_CLASSES_ROOT, "*\\shellex\\ContextMenuHandlers\\gvim") != ERROR_SUCCESS)
++fail;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved", 0,
KEY_WOW64_64KEY | KEY_ALL_ACCESS, &kh) != ERROR_SUCCESS)
@@ -107,11 +128,9 @@ remove_popup(void)
++fail;
RegCloseKey(kh);
}
- if (RegDeleteKeyEx(HKEY_LOCAL_MACHINE, "Software\\Vim\\Gvim",
- KEY_WOW64_64KEY, 0) != ERROR_SUCCESS)
+ if (reg_delete_key(HKEY_LOCAL_MACHINE, "Software\\Vim\\Gvim") != ERROR_SUCCESS)
++fail;
- if (RegDeleteKeyEx(HKEY_LOCAL_MACHINE, "Software\\Vim",
- KEY_WOW64_64KEY, 0) != ERROR_SUCCESS)
+ if (reg_delete_key(HKEY_LOCAL_MACHINE, "Software\\Vim") != ERROR_SUCCESS)
++fail;
if (fail == 6)
@@ -127,26 +146,19 @@ remove_openwith(void)
{
int fail = 0;
- if (RegDeleteKeyEx(HKEY_CLASSES_ROOT, "Applications\\gvim.exe\\shell\\edit\\command",
- KEY_WOW64_64KEY, 0) != ERROR_SUCCESS)
+ if (reg_delete_key(HKEY_CLASSES_ROOT, "Applications\\gvim.exe\\shell\\edit\\command") != ERROR_SUCCESS)
++fail;
- if (RegDeleteKeyEx(HKEY_CLASSES_ROOT, "Applications\\gvim.exe\\shell\\edit",
- KEY_WOW64_64KEY, 0) != ERROR_SUCCESS)
+ if (reg_delete_key(HKEY_CLASSES_ROOT, "Applications\\gvim.exe\\shell\\edit") != ERROR_SUCCESS)
++fail;
- if (RegDeleteKeyEx(HKEY_CLASSES_ROOT, "Applications\\gvim.exe\\shell",
- KEY_WOW64_64KEY, 0) != ERROR_SUCCESS)
+ if (reg_delete_key(HKEY_CLASSES_ROOT, "Applications\\gvim.exe\\shell") != ERROR_SUCCESS)
++fail;
- if (RegDeleteKeyEx(HKEY_CLASSES_ROOT, "Applications\\gvim.exe",
- KEY_WOW64_64KEY, 0) != ERROR_SUCCESS)
+ if (reg_delete_key(HKEY_CLASSES_ROOT, "Applications\\gvim.exe") != ERROR_SUCCESS)
++fail;
- if (RegDeleteKeyEx(HKEY_CLASSES_ROOT, ".htm\\OpenWithList\\gvim.exe",
- KEY_WOW64_64KEY, 0) != ERROR_SUCCESS)
+ if (reg_delete_key(HKEY_CLASSES_ROOT, ".htm\\OpenWithList\\gvim.exe") != ERROR_SUCCESS)
++fail;
- if (RegDeleteKeyEx(HKEY_CLASSES_ROOT, ".vim\\OpenWithList\\gvim.exe",
- KEY_WOW64_64KEY, 0) != ERROR_SUCCESS)
+ if (reg_delete_key(HKEY_CLASSES_ROOT, ".vim\\OpenWithList\\gvim.exe") != ERROR_SUCCESS)
++fail;
- if (RegDeleteKeyEx(HKEY_CLASSES_ROOT, "*\\OpenWithList\\gvim.exe",
- KEY_WOW64_64KEY, 0) != ERROR_SUCCESS)
+ if (reg_delete_key(HKEY_CLASSES_ROOT, "*\\OpenWithList\\gvim.exe") != ERROR_SUCCESS)
++fail;
if (fail == 7)
@@ -302,8 +314,7 @@ win95(void)
delete_uninstall_key(void)
{
#ifdef WIN3264
- RegDeleteKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Vim " VIM_VERSION_SHORT,
- KEY_WOW64_64KEY, 0);
+ reg_delete_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Vim " VIM_VERSION_SHORT);
#else
FILE *fd;
char buf[BUFSIZE];

0 comments on commit 315cc11

Please sign in to comment.