opening a file (word, notepad, excel etc.) in c++

I've been searching to no avail on how to open up a file in c++. I want to open something like a word file or a notepad file. An external file. How is it that i can open a file such as in c++?
i mean like to open it in a seperate window, not for input or output
Then launch the application with the file in the command line. Make sure to put the file path between "quotes".
I'm having a little trouble following you, can you give an example please?
Well... I'm gonna hate myself in the morning for this, but...

http://msdn.microsoft.com/en-us/library/bb762153(VS.85).aspx

-Albatross
quick and very dirty code
system("notepad file.txt");
that's so close, I was so excited to see a notepad file pop up lol

Do you know how to open up an already existing file?
ShellExecute mentioned bu Albatross above, uses the file associations to open a file using the correct app.
@blackcoder41:
STOP.
You have violated the C++ coding dogma.
Repent or burn forever in the hell known as GAS Assembly.

Okay, jk, but system() is evil. ;)

-Albatross
Last edited on
Albatross wrote:
STOP.
You have violated the C++ coding dogma.
Repent or burn forever in the hell known as GAS Assembly.

Okay, jk, but system() is evil. ;)
When a person can't be good they turn to the devil, lol
at this point, I'm so frustrated it's whatever works lol
Each OS has different way of associating files with programs. As such, there's no generic way to code it unless you wrap the possible methods with a generic function, which isn't the case here.

In Windows the method is to call ShellExecute. If you don't want to call it for religeous reasons, you'll just end up duplicating its functionality. There's more to programming than abstracting every nuance of every operating system.
Topic archived. No new replies allowed.