WinForm中启动Iexplorer.exe后判断网页

永远的AK47 2013-01-02 11:45:03
小弟现在需要这样的功能,在winform中要判断当前浏览器是否有打开指定网址的网页,若没有,则打开对应网页,若有则不再打开。请求大婶们给予帮助啊
...全文
225 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
nonocast 2013-01-03
  • 打赏
  • 举报
回复
引用 1 楼 BohemianLife 的回复:
C# code?12345678910111213141516171819202122232425SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindows(); bool isExist = false; foreach (SHDocVw.InternetExpl……
如果打开Safari或者Chrome用SHDocVw可以?
波西米亚人生 2013-01-03
  • 打赏
  • 举报
回复
SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindows();
             bool isExist = false;
            foreach (SHDocVw.InternetExplorer ie in shellWindows)
            {
                // 判斷視窗是否為 iexplore
                if (Path.GetFileNameWithoutExtension(ie.FullName).ToLower().Equals("iexplore"))
                {
                    mshtml.HTMLDocument hd = ie.Document as mshtml.HTMLDocument;
                    
                    if (ie.LocationURL == "http://www.baidu.com/")
                    {
                        isExist = true;
                    }
                              
                }
            }
            if (!isExist)
            {
                System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
                myProcess.StartInfo.FileName = "iexplore.exe";
                myProcess.StartInfo.Arguments = "http://www.baidu.com/";
                myProcess.Start();
            }

 
水猿兵团五哥 2013-01-03
  • 打赏
  • 举报
回复
引用 2 楼 nonocast 的回复:
引用 1 楼 BohemianLife 的回复:C# code?12345678910111213141516171819202122232425SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindows(); bool isExist = false; forea……
蛋疼的多浏览器
永远的AK47 2013-01-03
  • 打赏
  • 举报
回复
1楼的方法可行,高手们,都来看看,有没有更优秀的方法?

110,571

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧