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
{
}
}
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