title: Getting Installed softwares from remote host using wmi
body: <p>I want to retrieve Softwares installed from remote host. I want to get details from the registry and not from Win32_Product.I am using wmi. I have tried so many examples from the net. Most of them are in vb.net i need in C#. can any one post the code.. </p>
  
  <p>This is the code i am using</p>
  
  <pre><code>string regKeyToGet=@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\";
  string keyToRead= "DisplayName"; 
  ConnectionOptions oConn = new ConnectionOptions(); 
  oConn.Username = "Ravinilson"; 
  oConn.Password = "ravi"; 
  
  ManagementScope scope = new ManagementScope(@"//" + RemotePC + @"/root/default",      oConn); 
  ManagementClass registry = new ManagementClass(scope, new ManagementPath("StdRegProv"), null); 
  // Returns a specific value for a specified key 
  ManagementBaseObject inParams = registry.GetMethodParameters("GetStringValue"); 
  nParams["sSubKeyName"] = regKeyToGet; 
  inParams["sValueName"] = keyToRead; 
  ManagementBaseObject outParams = registry.InvokeMethod("GetStringValue", inParams, null); 
  return outParams["sValue"].ToString();
  </code></pre>
  
  <p>but it is giving "Object reference not set to an instance of an object" error.
  I am getting installed applications from "Win32_Product".But it is returning only windows products.That's why i want to get data from the registry "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\".</p>