如何获取当前激活的浏览器地址栏的网址?谢谢!

解决方案 »

  1.   

    HttpContext.Current.Request.Url
    用这个
      

  2.   

    找不到HttpContext,在 哪里可以引用,麻烦再指点一下。
      

  3.   

    我很菜啊,添加Systems.Web之后,
    下面这个还是不会用,再教教我了。谢谢!
    HttpContext.Current.Request.Url 
      

  4.   

    using System;
    using System.Text;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;namespace WindowsApplication13
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        [DllImport("user32.dll")]
            private static extern int FindWindow(string lpClassName, string lpWindowName);         [DllImport("user32.dll", SetLastError = true)]
            private static extern int FindWindowEx(int parentHandle, int childAfter, string className, string windowTitle);         [DllImport("user32.dll", EntryPoint = "SendMessage")]
            private static extern int SendMessage(int hWnd, uint Msg, int wParam, StringBuilder sb);        [DllImport("user32.dll")] 
            private static extern int GetForegroundWindow();        private const int WM_GETTEXT = 0x000D;        private void button1_Click(object sender, EventArgs e) 
            { 
                int hwnd;           // hwnd = GetForegroundWindow();
                hwnd = FindWindow("IEFrame", null);
                hwnd = FindWindowEx(hwnd, 0, "WorkerW", null);            StringBuilder sb = new StringBuilder(256);            hwnd = FindWindowEx(hwnd, 0, "ReBarWindow32", null);
                hwnd = FindWindowEx(hwnd, 0, "ComboBoxEx32", null);
                hwnd = FindWindowEx(hwnd, 0, "ComboBox", null);
                hwnd = FindWindowEx(hwnd, 0, "Edit", null);            if (hwnd != 0)
                {
                    SendMessage(hwnd, WM_GETTEXT, sb.Capacity, sb);
                    MessageBox.Show(sb.ToString());
                }
            }     }
    }
      

  5.   

    System.Web.HttpContext.Current.Request.Url
      

  6.   

    下面这样怎么不行啊,
      Uri  website = System.Web.HttpContext.Current.Request.Url;            
    Console.WriteLine(website);
      

  7.   

    Console.WriteLine?你到底要获得什么?浏览器地址是 webfrom 应用程序才会去获得。你要做的是什么?
      

  8.   

    晕,你的是windows form怎么获取url?
      

  9.   

    本程序为winform,在当前浏览器打开某个网址,想用本程序获取那个网址。
      

  10.   

    Request.RawUrl可以获得当前请求的URL。
      

  11.   

    System.Web.HttpContext.Current.Request.Url