简体   繁体   English

打开其中有3个选项卡的Internet Explorer Windows

[英]Opening an Internet Explorer Windows with Exactly 3 Tabs in it

I'm working on a project with a coworker and we have been beating our heads over our desks trying to figure this one out. 我正在与一位同事一起进行一个项目,我们一直在桌子上跳动,试图找出答案。 Our requirements are to have a new Internet Explorer browser pop up with one webpage and then append two tabs to it. 我们的要求是弹出一个带有一个网页的新Internet Explorer浏览器,然后在其上附加两个选项卡。 We found a solution that works on my coworker's computer, but when we tried it on my computer and another coworker's computer, it would not work. 我们找到了可以在我的同事的计算机上运行的解决方案,但是当我们在我的计算机和另一位同事的计算机上尝试该解决方案时,它将无法正常工作。 What we have so far: 到目前为止,我们拥有:

using SHDocVw;

...

ShellWindows iExplorerInstances = new ShellWindows();    
Process.Start("IExplore.exe", "www.reddit.com");
Thread.Sleep(5000);
string url = "http://www.google.com";
IEnumerator enumerator = iExplorerInstances.GetEnumerator();
enumerator.MoveNext();
InternetExplorer iExplorer = (InternetExplorer)enumerator.Current;
iExplorer.Navigate(url, 0x800); //0x800 means new tab 
url = "http://www.banana.com";
enumerator = iExplorerInstances.GetEnumerator();
enumerator.MoveNext();
iExplorer = (InternetExplorer)enumerator.Current;
iExplorer.Navigate(url, 0x800); //0x800 means new tab 

Again, this works correctly on only his computer. 同样,这只能在他的计算机上正常工作。 For me, when I try to run this code, it opens up the Internet Explorer browser correctly, but even though I'm using an InternetExplorer object, it opens up the tabs in Firefox. 对我来说,当我尝试运行此代码时,它会正确打开Internet Explorer浏览器,但是即使我使用的是InternetExplorer对象,它也会在Firefox中打开选项卡。 I delved into the class and tried to print out anything useful I could find. 我钻研了课,试图打印出所有我能找到的有用的东西。 The name property in my InternetExplorer object was "Windows Explorer". 我的InternetExplorer对象中的name属性是“ Windows资源管理器”。 I read up more on what ShellWindows actually does and that makes sense, but it doesn't help me. 我详细了解了ShellWindows的实际功能,这很有意义,但这对我没有帮助。 This seems to imply that it's opening up my default browser through the InternetExplorer object instead of Internet Explorer. 这似乎暗示它正在通过InternetExplorer对象而不是Internet Explorer打开我的默认浏览器。 I also had different results from my coworker who has Chrome as a default browser. 我的同事使用Chrome作为默认浏览器的结果也有所不同。 I switched my default browser to Chrome to see if that was the issue, but then the two extra tabs opened in Chrome. 我将默认浏览器切换为Chrome,以查看是否存在此问题,但是随后在Chrome中打开了两个额外的标签。 All I really need is to open an Internet Explorer browser with 3 tabs each with their own URL. 我真正需要的是打开一个Internet Explorer浏览器,其中包含3个带有各自URL的选项卡。 Any help is greatly appreciated. 任何帮助是极大的赞赏。

looks like this guy has the solution you are looking for: 看起来这个人有您要寻找的解决方案:

Launch a URL in a tab in an existing IE window from C# 从C#在现有IE窗口中的选项卡中启动URL

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM