那位高手有空?请问 C# 如果获取当前系统的 IE 的 User-Agent ?"User-Agent", 如:"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; InfoPath.2; .NET4.0C; .NET4.0E; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"

解决方案 »

  1.   

     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[] { });
                MessageBox.Show( userAgent.ToString());