summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2010-08-02 23:06:46 +0200
committerBram Moolenaar <Bram@vim.org>2010-08-02 23:06:46 +0200
commitbf65051b7bbb84436159570ae095ba6e2c7249d6 (patch)
treea83365f52cc31476142fa1ea558020724f6d61be
parent61a91766f7558ae9914eb85377a32d7f6afe178c (diff)
downloadvim-git-bf65051b7bbb84436159570ae095ba6e2c7249d6.tar.gz
Windows uninstaller: Instead of calling RegDeleteKeyEx() directly load it
dynamically from the .dll. Should work everywhere.
-rw-r--r--runtime/doc/todo.txt4
-rw-r--r--src/dosinst.h1
-rw-r--r--src/uninstal.c63
3 files changed, 41 insertions, 27 deletions
diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt
index 7b9c977db..2db0ae250 100644
--- a/runtime/doc/todo.txt
+++ b/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)
diff --git a/src/dosinst.h b/src/dosinst.h
index 444af45b2..b33426ad7 100644
--- a/src/dosinst.h
+++ b/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
diff --git a/src/uninstal.c b/src/uninstal.c
index 13138aafb..99cdc679c 100644
--- a/src/uninstal.c
+++ b/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];