I was wondering if it is possible to open an internet browser window by calling a function in c++. If it is possible could you please post the code to do so.
Thank You Very Much!
Printable View
I was wondering if it is possible to open an internet browser window by calling a function in c++. If it is possible could you please post the code to do so.
Thank You Very Much!
You can START another application by calling some function in your code, yes. But you need to know what the application is (e.g. firefox, internet explorer, opera or whatever else).
You can probably use "exec" or "system" to do this.
--
Mats
I want to open a specific webpage in Internet Explorer what is the most effective way to do that
Thanks!
The most efficient - that's a difficult question, as it depends on what you want to be efficient, the time it takes to load internet explorer will be much bigger factor than what you do in your program, if you are after performance.
If on the other hand you are asking "what's the shortest code I need to write to do that", thenis a pretty simple way to do it.Code:system("iexplore http://www.somesite.com/somepath/somepage.html");
--
Mats
that will do just fine
Thanks
c++ says thats not a valid command
That 'what' isn't a valid command? system? or something else?
if you're using the system function, I believe you need to #include <cstdlib> at the top of your program.
whatever you put between the double-quotes for the system function is entirely dependent on your system, your version of your O/S, etc. If your computer doesn't have internet explorer installed, then calling "iexplore ..." won't do anything. (Although some versions call it 'explorer' rather than 'iexplore')
in short - if you put something into system() that doesn't work when typed from the commandline on your computer, then you can pretty much guarantee that it won't work in your program either.
I put in this line
system("iexplore http://www.madigangames.com/default.aspx");
and I get this error at runtime (in the console window)
'iexplore' is not reconized as an internal or external command,
operable program or batch file.
Check the FAQ on how to run another program from within your program. There are other examples that might work better (I think ShellExecute might be best for you there). For example, you might be able to just run the web address and windows will automatically load it in the default browser.
Also, for this particular problem with system, what happens if you open a console window and type the same iexplore command?
Thanks
I could not find it in the FAQ
Thanks
>> I could not find it in the FAQ
It is the one that says "Run a program from within a program."
Is their a system function that will open a webpage? Im not looking for anything complicated.
Thanks
What is wrong with the suggested solution?
Call ShellExecute() like people said.
Or you could try this solution I saw somewhere before:
Execute rundll32 with the following args:
- "url.dll"
- "FileProtocolHandler"
- Whatever your link is
Something like that. That's not anything complicated.Code:ShellExecute(current_hwnd, "open", "http://www.booyah.com", NULL, NULL, SW_SHOWNORMAL);
The reason that you can't execute iexplore with just iexplore is that the shell can't find iexplore. iexplore needs to be in the path (which is rare) or else you need to pass the full path to it, like "\Program Files\Internet Explorer\iexplorer.exe".
But, of course, the easier way to do it is to use ShellExecute(). You can pass ShellExecute() a file, and it will run the program that you have set to open that type of file by default, just as if you'd double-clicked on the file in explorer.
Note that you'll have to include <windows.h> to use ShellExecute(): ShellExecute() is a Windows-only function and thus by using it you sacrifice some portability.
[edit] On the other hand, explorer.exe is almost always in the path, so if you want to open a folder for the user to view, you can just call
(. is the current directory.)[/edit]Code:system("explorer.exe .");
I wont work can someone post a solution
>> I wont work can someone post a solution
Several solutions have been posted, including one that several people agree is probably best. If you are having trouble implementing that solution, feel free to explain what is not working and maybe we can help you get it working.
I'm assuming it was a typo to say "I" instead of "It", but it seems to fit anyway. :rolleyes:
Don't be so freaking lazy. Even the way you tell us you have trouble is an example of laziness. For those of us that take the time to try to help you, couldn't you do us the favor of telling us what isn't working? Tell us what you tried, what you expected it to do, and what actually happened.
Try to learn how to learn. That's what good programmers must conquer. If you get a job as a programmer, and you're using some software written by some other company, and you're having trouble figuring it out, do you think their tech support wants to hear you say, "It won't work."? I think not.
Try again.
My response was posted much later than I had sent it. I was unaware of the shell execute post when I made my post. I feel that your personal attacks are uncalled for.
I am getting this error with this line
ShellExecute(current_hwnd, "open", "http://www.mywebs.com", NULL, NULL, SW_SHOWNORMAL);
error C2065: 'current_hwnd' : undeclared identifier
>> I was unaware of the shell execute post when I made my post.
ShellExecute was actually suggested twice a full 24 hours earlier.
Unfortunately there is a little more to it than what was in CodeMonkey's example. Use the example in the FAQ, it is more complete and has comments describing a little bit of what it is doing.
BTW, the FAQ I'm referring to is the link in the bar at the top of the page that says FAQ (not the FAQ board if that is where you were looking).
I guess six(6) Thank Yous (Im sorry that some of them are "Thanks") are not enought.
enough