comparison src/if_ole.cpp @ 2474:a29301e7c05f vim73

Take OLE registration back to 32 bit registry, the unregister wasn't working for the 64 registry.
author Bram Moolenaar <bram@vim.org>
date Mon, 02 Aug 2010 22:13:25 +0200
parents 336d6df580e7
children 04736b4030ec
comparison
equal deleted inserted replaced
2473:d55e70cabe2c 2474:a29301e7c05f
83 #define MYPROGID "Vim.Application.1" 83 #define MYPROGID "Vim.Application.1"
84 #define MYVIPROGID "Vim.Application" 84 #define MYVIPROGID "Vim.Application"
85 85
86 #define MAX_CLSID_LEN 100 86 #define MAX_CLSID_LEN 100
87 87
88 /*
89 * Modern way of creating registry entries, also works on 64 bit windows when
90 * compiled as a 32 bit program.
91 */
92 # ifndef KEY_WOW64_64KEY
93 # define KEY_WOW64_64KEY 0x0100
94 # define RegDeleteKeyEx(a, b, c, d) RegDeleteKey(a, b)
95 # endif
96
97 /***************************************************************************** 88 /*****************************************************************************
98 2. The application object 89 2. The application object
99 *****************************************************************************/ 90 *****************************************************************************/
100 91
101 /* Definition 92 /* Definition
165 156
166 // Check we can write to the registry. 157 // Check we can write to the registry.
167 // RegCreateKeyEx succeeds even if key exists. W.Briscoe W2K 20021011 158 // RegCreateKeyEx succeeds even if key exists. W.Briscoe W2K 20021011
168 if (RegCreateKeyEx(HKEY_CLASSES_ROOT, MYVIPROGID, 0, NULL, 159 if (RegCreateKeyEx(HKEY_CLASSES_ROOT, MYVIPROGID, 0, NULL,
169 REG_OPTION_NON_VOLATILE, 160 REG_OPTION_NON_VOLATILE,
170 KEY_WOW64_64KEY | KEY_ALL_ACCESS, NULL, &hKey, NULL)) 161 KEY_ALL_ACCESS, NULL, &hKey, NULL))
171 { 162 {
172 delete me; 163 delete me;
173 return NULL; // Unable to write to registry. Quietly fail. 164 return NULL; // Unable to write to registry. Quietly fail.
174 } 165 }
175 RegCloseKey(hKey); 166 RegCloseKey(hKey);
658 static void RecursiveDeleteKey(HKEY hKeyParent, const char *child) 649 static void RecursiveDeleteKey(HKEY hKeyParent, const char *child)
659 { 650 {
660 // Open the child 651 // Open the child
661 HKEY hKeyChild; 652 HKEY hKeyChild;
662 LONG result = RegOpenKeyEx(hKeyParent, child, 0, 653 LONG result = RegOpenKeyEx(hKeyParent, child, 0,
663 KEY_WOW64_64KEY | KEY_ALL_ACCESS, &hKeyChild); 654 KEY_ALL_ACCESS, &hKeyChild);
664 if (result != ERROR_SUCCESS) 655 if (result != ERROR_SUCCESS)
665 return; 656 return;
666 657
667 // Enumerate all of the decendents of this child 658 // Enumerate all of the decendents of this child
668 FILETIME time; 659 FILETIME time;
701 692
702 // Create and open key and subkey. 693 // Create and open key and subkey.
703 long result = RegCreateKeyEx(HKEY_CLASSES_ROOT, 694 long result = RegCreateKeyEx(HKEY_CLASSES_ROOT,
704 buffer, 695 buffer,
705 0, NULL, REG_OPTION_NON_VOLATILE, 696 0, NULL, REG_OPTION_NON_VOLATILE,
706 KEY_WOW64_64KEY | KEY_ALL_ACCESS, NULL, 697 KEY_ALL_ACCESS, NULL,
707 &hKey, NULL); 698 &hKey, NULL);
708 if (result != ERROR_SUCCESS) 699 if (result != ERROR_SUCCESS)
709 return; 700 return;
710 701
711 // Set the value 702 // Set the value