Is there any way to open a windows file or program through C++?
Printable View
Is there any way to open a windows file or program through C++?
Yes. You can use the system() command.
It can be a security issue if it's used incorrectly though. For instance, don't let users input whatever they want into a string that is presumable a file they're supposed to open and just throw that into the system command.Code:system("notepad");
ok thanx :)
There are other options like ShellExecute or CreateProcess. There is a FAQ entry on running other programs I believe.
start automatically opens a document with the default program (like ShellExecute). ie:
will open hello.c with whatever your IDE for .c files is.Code:system("start hello.c");
[edit]
FAQ entry: http://faq.cprogramming.com/cgi-bin/...&id=1043284392
[/edit]