Start an external program in C++

How can I start up an external program like Firefox using my C++ program?
Preferably avoiding system(). I read someplace to use CreateProcess() but when I tried it, it flipped out.

- TruYadoo
I added "system("\"c:/program_files_x86/mozilla_firefox/firefox.exe\"");" just to see if I could get it to work and I'm now getting an error "The system cannot find the path specified."

@ collator: Do you mean this?
int system(const char *firefox);
If I try using CreateProcess(), it opens a new file with over 2000 lines.
With two errors.
# 1 @ line 69: "at this point in file"
# 2 @ line 1249: "too few arguments to function 'BOOL CreateProcessA(const CHAR*, ...."

I've searched google a lot and have found several posts of people advising the use of CreateProcess(), I just can't seem to get it to work.

Under my if(), I have:
CreateProcess("\"c:/program files/mozilla firefox/firefox.exe\"");
Is that correct?
I just got Microsoft Word and Firefox to open by using:
system("START firefox/WINWORD");

So it works but how can I do it without using system?
The CreateProcess is a little more complicated than that.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx

You'll need to do something along the lines of:
1
2
3
4
5
LPCTSTR path = "\"c:/program files/mozilla firefox/firefox.exe\"";
STARTUPINFO startup = {sizeof(STARTUPINFO), NULL, NULL, "FireFox", 0,0,800, 600, NULL, NULL, NULL,
NULL, NULL, 0, NULL, NULL, NULL, NULL  };
PROCESS_INFORMATION pinfo;
CreateProcess(path, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS,NULL,NULL, &startup, &pinfo); 
Last edited on
So my program is working just fine [still using system("start ?") though] and all the programs will work except Norton. I'm getting "uistub" is the application file but system("start uistub") doesnt work even though thats how i have everything else set which works fine. Is Norton just stupid like that?
I hate Norton. Anti-virus programs will have additional protections to prevent a virus from closing or manipulating them. So yes, Norton is just stupid like that.
Dangit. So, I bet this isn't a beginner thing but I already have this thread so I'll ask anyways. (Only started learning C++ like 3 days ago.. i learn kinda fast lol)
Is there a way to get MY program to update itself when it detects other newly installed programs?
For example, I have my program set to start Firefox is the user inputs "Firefox".

Lets say that I don't already have Notepad++ installed.
How would I get MY program to automatically detect that i just installed Notepad ++ (for example) and update itself to include Notepad++ into my program? (however u explain it lol)
Oh, is Google Chrome stupid like Norton? I can't seem to get it to work either.
Topic archived. No new replies allowed.