Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
171 views
in Technique[技术] by (71.8m points)

how to retrieve URL from browser using c#

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
    {
    }
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...