title: How can I access 64 bit registry hive information from a application running in 32 bit mode on a 64 bit machine(WOW) using WMI through C#
body: <p>I think the question really sums up what i'm trying to do. Here is the code that i'm using. It works in every scenario except if my application is running in 32 bit mode on a 64 bit machine. No matter how I play arround with the __ProviderArchitecture and __RequiredArchitecture flags, i can always only seem to access the 32 bit section of the hive (WOW6432Node)</p>
  
  <pre><code>uint LOCAL_MACHINE = 0x80000002;
  string results = "";
  ConnectionOptions options = new ConnectionOptions();
  options.Impersonation = ImpersonationLevel.Impersonate;
  options.EnablePrivileges = true;
  options.Username = this.txtUser.Text;
  options.Password = this.txtPassword.Text;
  
  ManagementScope myScope = new ManagementScope("\\\\" + this.txtMachine.Text + "\\root\\default", options);
  ManagementPath mypath = new ManagementPath("StdRegProv");
  ManagementClass mc = new ManagementClass(myScope, mypath, null);
  
  ManagementBaseObject inParams = mc.GetMethodParameters("EnumKey");
  inParams["hDefKey"] = LOCAL_MACHINE;
  inParams["sSubKeyName"] = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
  
  ManagementNamedValueCollection objCtx = new ManagementNamedValueCollection();
  objCtx.Add("__ProviderArchitecture", 64);
  objCtx.Add("__RequiredArchitecture", true);
  
  
  InvokeMethodOptions invokeOptions = new InvokeMethodOptions();
  invokeOptions.Context = objCtx;
  ManagementBaseObject outParams = mc.InvokeMethod("EnumKey", inParams, invokeOptions);
  
  inParams = mc.GetMethodParameters("GetStringValue");
  inParams["hDefKey"] = LOCAL_MACHINE;
  
  foreach(string name in (string[])outParams["sNames"])
  {
        inParams["sSubKeyName"] = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" + "\\" + name;
        inParams["sValueName"] = "DisplayName";
        outParams = mc.InvokeMethod("GetStringValue", inParams, invokeOptions);
  
        if (!string.IsNullOrEmpty(((string)outParams["sValue"])))
        {
            results += outParams["sValue"] + "\t";
        }
   }
  </code></pre>