title: Identify COM port using VID and PID for USB device attached to x64
body: <p>As following i able to get usb com port names attached to 32bit win7OS machine, by given pid and vid,but when running in x64 it stuck in the following line: </p>
  
  <pre><code>comports.Add((string)rk6.GetValue("PortName"));
  </code></pre>
  
  <p>This is my code </p>
  
  <pre><code>static List&lt;string&gt; ComPortNames(String VID, String PID)
      {
          String pattern = String.Format("^VID_{0}.PID_{1}", VID, PID);
          Regex _rx = new Regex(pattern, RegexOptions.IgnoreCase);
          List&lt;string&gt; comports = new List&lt;string&gt;();
  
          RegistryKey rk1 = Registry.LocalMachine;
          RegistryKey rk2 = rk1.OpenSubKey("SYSTEM\\CurrentControlSet\\Enum");
  
          foreach (String s3 in rk2.GetSubKeyNames())
          {
  
              RegistryKey rk3 = rk2.OpenSubKey(s3);
              foreach (String s in rk3.GetSubKeyNames())
              {
                  if (_rx.Match(s).Success)
                  {
                      RegistryKey rk4 = rk3.OpenSubKey(s);
                      foreach (String s2 in rk4.GetSubKeyNames())
                      {
                          RegistryKey rk5 = rk4.OpenSubKey(s2);
                          RegistryKey rk6 = rk5.OpenSubKey("Device Parameters");
                          comports.Add((string)rk6.GetValue("PortName"));
                      }
                  }
              }
          }
          return comports;
      }
  </code></pre>
  
  <p>actual code get <a href="http://www.codeproject.com/Tips/349002/Select-a-USB-Serial-Device-via-its-VID-PID" rel="noreferrer">here</a>, So how to get com port names in x64, any suggestion?</p>