获取webbrowser的useragent

来源:互联网 发布:广州龙族网络 编辑:程序博客网 时间:2024/05/29 18:43
private string getuseragent()
{
WebBrowser wb = new WebBrowser();
wb.Navigate("about:blank");
while (wb.IsBusy) Application.DoEvents();
object window = wb.Document.Window.DomWindow;
Type wt = window.GetType();
object navigator = wt.InvokeMember("navigator", BindingFlags.GetProperty,null, window, new object[] { });
Type nt = navigator.GetType();
object userAgent = nt.InvokeMember("userAgent", BindingFlags.GetProperty,null, navigator, new object[] { });
return userAgent.ToString();
}
原创粉丝点击