2
votes

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. 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. 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". I read up more on what ShellWindows actually does and that makes sense, but it doesn't help me. This seems to imply that it's opening up my default browser through the InternetExplorer object instead of Internet Explorer. I also had different results from my coworker who has Chrome as a default browser. I switched my default browser to Chrome to see if that was the issue, but then the two extra tabs opened in Chrome. All I really need is to open an Internet Explorer browser with 3 tabs each with their own URL. Any help is greatly appreciated.

1
Are you allowed to open it on a file? If so, you could try opening it on a file which in turn opens multiple pages from the same instance, which should open multiple tabs. I'm not sure how reliable this behavior is...RonaldBarzell
The actual code is going to be embedded into a tray application that pops these windows when a certain condition is met. It will be installed on several computers, and I'm not certain that using a file is going to be the best choice of implementation.user1827607
Those are some strange requirements which seem to be counter to a good user experience. Can you not combine your datasources and display them in a single page?spender
To be more specific, this application is going to be run on an automated machine that is performing particular actions that interact with customers. These pages are supposed to pop up three webpages (one has actual customer data, two more are Google searches based on data set in DDE) so that anyone who checks in on the machine can view all of this data without having to dig for it. The requirements are pretty strange, but that's what they're paying us for.user1827607
then why not just make IE the default browser on that specific machine?Jay

1 Answers

0
votes

looks like this guy has the solution you are looking for:

Launch a URL in a tab in an existing IE window from C#