-1

I am working on a windows application using c# . I want to retrieve URL from browser. but i am unable to do this .

private void WebListLoad()
{
    ListViewItem lvi;
    Process[] prs = Process.GetProcessesByName("firefox");
    try
    {

    //int handle = int.Parse(Console.ReadLine(), NumberStyles.HexNumber);
    //int txtLength = SendMessage(handle, WM_GETTEXTLENGTH, 0, 0);
    //StringBuilder sb = new StringBuilder(txtLength + 1);
    //SendMessage(handle, WM_GETTEXT, sb.Capacity, sb);


        foreach (Process proces in prs)
        {
            if (proces.MainWindowTitle.Length > 0)
            {
                lvi = listView2.Items.Add(System.Environment.UserName);
                lvi.SubItems.Add("");
                lvi.SubItems.Add(proces.MainWindowTitle.ToString());
                lvi.SubItems.Add(proces.StartTime.ToString());
            }
        }
    }
    catch
    {
    }
}
Cœur
  • 37,241
  • 25
  • 195
  • 267
ankush
  • 1,051
  • 3
  • 19
  • 34

2 Answers2

1

Firefox is a multi-tabbed browser, so getting the address of each of the tabs is not going to be easy.

You will probably need to make a Firefox plugin that communicates with your C# app and supplies it the addresses of the tabs.

Alternatively, see this url: http://social.msdn.microsoft.com/forums/en/csharpgeneral/thread/c60b1699-9fd7-408d-a395-110c1cd4f297

andreialecu
  • 3,639
  • 3
  • 28
  • 36
0
string WebText = "";
foreach (InternetExplorer ie in new ShellWindowsClass())
{
    filename = Path.GetFileNameWithoutExtension(ie.FullName).ToLower();
    if (filename == "iexplore")
    Url = ie.LocationURL.ToString();
}
Jason Plank
  • 2,336
  • 5
  • 31
  • 40
ankush
  • 1,051
  • 3
  • 19
  • 34