如何获取当前浏览器地址 如何获取当前激活的浏览器地址栏的网址?谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 HttpContext.Current.Request.Url用这个 找不到HttpContext,在 哪里可以引用,麻烦再指点一下。 我很菜啊,添加Systems.Web之后,下面这个还是不会用,再教教我了。谢谢!HttpContext.Current.Request.Url 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()); } } }} System.Web.HttpContext.Current.Request.Url 下面这样怎么不行啊, Uri website = System.Web.HttpContext.Current.Request.Url; Console.WriteLine(website); Console.WriteLine?你到底要获得什么?浏览器地址是 webfrom 应用程序才会去获得。你要做的是什么? 晕,你的是windows form怎么获取url? 本程序为winform,在当前浏览器打开某个网址,想用本程序获取那个网址。 Request.RawUrl可以获得当前请求的URL。 System.Web.HttpContext.Current.Request.Url winfrom给image添加点击事件 求一个c#例子:每10秒执行一次某方法 c++函数翻译成.net,求解 窗体值传递出了问题 请问这是哪种编码 谢谢了 页面直接调用类中的方法问题,(<%#方法%>这类的问题) 望指教:有关于textbox的一个小问题,高手帮帮忙哦,不胜感激! ArrayList和Hashtable里对一个元素的访问的同步是用ReaderWriterLock实现的,还是用lock实现的?? 求C# 怎样连接MySQL 小数存入oracle数据库的float 类型字段后小数点后面多了好多位数 如何验证xml是正确的? 50求一个正则表达式,很简单的,在线等
用这个
下面这个还是不会用,再教教我了。谢谢!
HttpContext.Current.Request.Url
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());
}
} }
}
Uri website = System.Web.HttpContext.Current.Request.Url;
Console.WriteLine(website);