Thread: Can you call firefox from C++?

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    57

    Can you call firefox from C++?

    Can you call installed programs like firefox from C++ code? I would like to do this with arguements, such as which html file to open.

    I suppose it would be some kind of call to the operating system?

  2. #2
    Registered User
    Join Date
    May 2006
    Posts
    57
    Could this be done in C++ .NET?

  3. #3
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Take a look at the spawn functions.
    It would probably also be best to read where the programs are installed by looking in the registry rather than hard coding it, but just take it one step at a time for now.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  4. #4
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507
    Just CreateProcess(); it with the appropriate command line parameters that firefox takes for opening a certain html file. http://msdn.microsoft.com/en-us/library/ms682425.aspx

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    ShellExecute is typically better if you ask me. No stupid handles to close, and it is easier to call.
    But this assumes the platform is Windows.

    Regardless, since there is a C runtime function, use it.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    ShellExecute is indeed the preferred method on Windows. It launches the URL using the default browser configured on the PC, which I would imagine you have set to Firefox in the "Set Program Access and Defaults" page of the "Add or Remove Programs" control panel, if you're a regular Firefox user. For those that just have IE, it launches that etc.
    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"

  7. #7
    Registered User
    Join Date
    May 2006
    Posts
    57
    Thanks. It looks like lots of info to give me a good start.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. minix system call pls help for project
    By porvas in forum Linux Programming
    Replies: 2
    Last Post: 06-14-2009, 02:40 AM
  2. Error C2664 - Trying to call an external Dll
    By jamez05 in forum C++ Programming
    Replies: 3
    Last Post: 08-08-2006, 06:07 AM
  3. Class won't call
    By Aalmaron in forum C++ Programming
    Replies: 3
    Last Post: 04-13-2006, 04:57 PM
  4. Iterative Tree Traversal using a stack
    By BigDaddyDrew in forum C++ Programming
    Replies: 7
    Last Post: 03-10-2003, 05:44 PM
  5. call by reference and a call by value
    By IceCold in forum C Programming
    Replies: 4
    Last Post: 09-08-2001, 05:06 PM