Jump to content
  • Advertisement
Sign in to follow this  
v0dKA

ShellExecute() - make IE open in a new window?

This topic is 4914 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Quick question: Is it possible to make Internet Explorer open in a new window via the command line? I tried:
#include <windows.h>

INT WINAPI WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR, INT )
{
	ShellExecute( NULL, "open", "C:\Program Files\Internet Explorer\iexplore.exe -new", NULL, NULL, SW_SHOWNORMAL);
	return 0;
}

Unfortunately, that steals any presently opened window and steals whatever is open there. Is there an alternative method? All I want is for it to get a new brower window. Any help would be appreciated.

Share this post


Link to post
Share on other sites
Advertisement
I got it to work well with CreateProcess:


STARTUPINFO si = { 0, };
si.cb = sizeof( STARTUPINFO );
PROCESS_INFORMATION pi = { 0, }, pi2 = { 0, };
CreateProcess( "c:\\Program Files\\Internet Explorer\\iexplore.exe", "iexplore.exe", NULL, NULL, FALSE,
NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi );
CreateProcess( "c:\\Program Files\\Internet Explorer\\iexplore.exe", "iexplore.exe www.google.com", NULL, NULL, FALSE,
NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi2 );





May I ask why you must use Internet Explorer? I know some people find it annoying to have a program open up IE instead of their default browser.

[edit] I just noticed you didn't escape your backslashes ("\" instead of "\\"). Is this just for the example?

[edit2] Try putting -new in the lpParameters argument of the ShellExecute function (if you must use -new).


Regards,
jflanglois

Share this post


Link to post
Share on other sites
the best way to do this IMHO, is to use shellexecute like this

ShellExecute( NULL, "open", "HTTP://www.google.com.au", NULL, NULL, SW_SHOWNORMAL);

that way it will use the default browser on the machine instead of spawning a specific one. I'd hate it if a program opened IE instead of firefox :)

Share this post


Link to post
Share on other sites
This isn't a program I'm planning to release. It's simply a time saver feature I'm hoping to implement. For example, I need dictionary.com often, and I was hoping to have my program run in the background, so I could use some quick keyboard shortcut to bring up a text prompt. All I'd have to do is enter the word, and the program would retrieve the defenitions. The implementation comes later, but for now I was hoping to get the basics down [smile].

As for double backslashes - wow, I just noticed that too! It worked fine for some strange reason. But then again, I'm using buggy old VC++ 6.0 still, so...

Share this post


Link to post
Share on other sites
Quote:
Original post by v0dKA
Quick question: Is it possible to make Internet Explorer open in a new window via the command line?


What OS are u running?
ShellExecute(NULL,"c:\\program files\\internet explorer\iexplore.exe", NULL, SW_SHOWNORMAL) works fine for me in XP.

Share this post


Link to post
Share on other sites
The problem is not how you are executing. The problem is that you are trying to override user settings in IE. In IE, go to tools, options, and uncheck the "Reuse windows for launching shortcuts". *That* is the correct method of controlling whether IE creates a new Window or uses the last focused one to launch shell requests(like when you double click a jpeg file)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!