Bug 458935 - Make Windows Search registry key verification work correctly on Vista x64; r=(bienvenu + beckley)
authorSiddharth Agarwal <sid1337@gmail.com>
Thu, 09 Oct 2008 17:56:32 +0200
changeset 565 5d73f2badfb29abb01eccdfd1dcd192884d86fb9
parent 564 38cb09a53f4c88f9a0347dfb9b3a866f344f5bae
child 566 b9559bf7af5e3813ed3d5a272c9e831dcee86f55
push idunknown
push userunknown
push dateunknown
bugs458935
Bug 458935 - Make Windows Search registry key verification work correctly on Vista x64; r=(bienvenu + beckley)
mail/components/search/nsWinSearchIntegration.js
--- a/mail/components/search/nsWinSearchIntegration.js
+++ b/mail/components/search/nsWinSearchIntegration.js
@@ -90,20 +90,17 @@ function InitWinSearchIntegration()
   if (!serviceRunning)
   {
     SIDump("Windows Search service not running\n");
     InitSupportIntegration(false);
     return;
   }
 
   gFoldersInCrawlScope = gWinSearchHelper.foldersInCrawlScope;
-  // XXX disable CheckRegistryKeys for now, we'll just harmlessly elevate every
-  // time the status goes from disabled to enabled
-  // gRegKeysPresent = CheckRegistryKeys();
-  gRegKeysPresent = false;
+  gRegKeysPresent = CheckRegistryKeys();
 
   if (enabled === undefined)
     // First run has to be handled after the main mail window is open
     return true;
 
   if (enabled)
     SIDump("Initializing Windows Search integration\n");
   InitSupportIntegration(enabled);
@@ -178,26 +175,27 @@ const gRegKeys =
   {
     root: Ci.nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE,
     key: "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\explorer\\KindMap",
     name: ".wdseml",
     value: "email;communication"
   }
 ];
 
+// Required to access the 64-bit registry, even though we're probably a 32-bit program
+const ACCESS_WOW64_64KEY = 0x0100;
+
 // Check whether the required registry keys exist
-// TODO: handle the 64 bit registry on 64 bit Windows, via probably moving this
-// to the helper component
 function CheckRegistryKeys()
 {
   for (var i = 0; i < gRegKeys.length; i++)
   {
     var regKey = Cc["@mozilla.org/windows-registry-key;1"].createInstance(Ci.nsIWindowsRegKey);
     try {
-      regKey.open(gRegKeys[i].root, gRegKeys[i].key, regKey.ACCESS_READ);
+      regKey.open(gRegKeys[i].root, gRegKeys[i].key, regKey.ACCESS_READ | ACCESS_WOW64_64KEY);
     }
     catch (e) { return false; }
     var valuePresent = regKey.hasValue(gRegKeys[i].name) &&
                         (regKey.readStringValue(gRegKeys[i].name) == gRegKeys[i].value);
     regKey.close();
     if (!valuePresent)
       return false;
   }