Thread: Internet Window???

  1. #1
    Registered User
    Join Date
    Jul 2007
    Posts
    75

    Question Internet Window???

    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!

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    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

  3. #3
    Registered User
    Join Date
    Jul 2007
    Posts
    75
    I want to open a specific webpage in Internet Explorer what is the most effective way to do that

    Thanks!

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    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", then
    Code:
        system("iexplore http://www.somesite.com/somepath/somepage.html");
    is a pretty simple way to do it.

    --
    Mats

  5. #5
    Registered User
    Join Date
    Jul 2007
    Posts
    75
    that will do just fine

    Thanks

  6. #6
    Registered User
    Join Date
    Jul 2007
    Posts
    75
    c++ says thats not a valid command

  7. #7
    Registered User
    Join Date
    Feb 2006
    Posts
    312
    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.
    Last edited by Bench82; 08-14-2007 at 08:56 AM.

  8. #8
    Registered User
    Join Date
    Jul 2007
    Posts
    75
    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.

  9. #9
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    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?

  10. #10
    Registered User
    Join Date
    Jul 2007
    Posts
    75
    Thanks

  11. #11
    Registered User
    Join Date
    Jul 2007
    Posts
    75
    I could not find it in the FAQ

    Thanks

  12. #12
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Quote Originally Posted by Daved View Post
    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.
    Exactly! Don't explicitly execute iexplore. Just give the url to ShellExecute and let the default browser handle it. This is what your users will want.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  13. #13
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    >> I could not find it in the FAQ

    It is the one that says "Run a program from within a program."

  14. #14
    Registered User
    Join Date
    Jul 2007
    Posts
    75
    Is their a system function that will open a webpage? Im not looking for anything complicated.

    Thanks

  15. #15
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    What is wrong with the suggested solution?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 08:23 AM
  2. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  3. Pong is completed!!!
    By Shamino in forum Game Programming
    Replies: 11
    Last Post: 05-26-2005, 10:50 AM
  4. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 10:01 PM