title: C# get URLs of all open pages in Firefox
body: <p>I have already been here:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/15447518/c-sharp-get-url-from-firefox-but-dont-use-dde">C# get URL from firefox but don&#39;t use DDE</a></li>
  <li><a href="https://stackoverflow.com/questions/7814027/how-can-i-get-urls-of-open-pages-from-chrome-and-firefox">How can I get URLs of open pages from Chrome and Firefox?</a></li>
  <li><a href="https://stackoverflow.com/questions/40434679/c-sharp-get-all-open-browsing-tabs-in-all-instances-of-firefox">C# - Get all open browsing tabs in all instances of firefox</a></li>
  <li><a href="https://social.msdn.microsoft.com/Forums/vstudio/en-US/93001bf5-440b-4a3a-ad6c-478a4f618e32/how-can-i-get-urls-of-open-pages-from-chrome-and-firefox?forum=csharpgeneral" rel="nofollow noreferrer">https://social.msdn.microsoft.com/Forums/vstudio/en-US/93001bf5-440b-4a3a-ad6c-478a4f618e32/how-can-i-get-urls-of-open-pages-from-chrome-and-firefox?forum=csharpgeneral</a></li>
  <li><a href="https://stackoverflow.com/questions/430614/get-firefox-url">Get Firefox URL?</a></li>
  </ul>
  
  <p>I know there are lots of questions already out there about this topic, BUT none of them answers it correctly. I am curious how to get the URL of all open pages in firefox, but i dont find a solution that provides working code.</p>
  
  <p>This is the most rewarded solution on the internet, but it does not work for me.
  This code uses DDE (which used NDDE - a good DDE wrapper for .NET):</p>
  
  <pre><code>private string GetBrowserURL(string browser)
  {
      try
      {
          DdeClient dde = new DdeClient(browser, "WWW_GetWindowInfo");
          dde.Connect();
          string url = dde.Request("URL", int.MaxValue);
          string[] text = url.Split(new string[] { "\",\"" }, StringSplitOptions.RemoveEmptyEntries);
          dde.Disconnect();
          return text[0].Substring(1);
      }
      catch
      {
          return null;
      }
  }
  </code></pre>
  
  <hr>
  
  <p>I dont care about if it shows the history, gets the URLs of open pages in a second Firefox window, i want to keep it simple by now. Please dont provide me code for another browser as it is always browser specific or any VB code.</p>