-2

On Windows, how do I get my app to tell another app to open a file that I just generated. For example, "WordPad, please open 'foo.rtf' that I just made." Or Word, or other big apps that may already be open with other files. I have to assume that the app may or may not be open already.

Alternatively, if I could only do the equivalent of double-clicking the file, so as to open it with its default application, that would still be all right.

Joymaker
  • 813
  • 1
  • 9
  • 23

1 Answers1

0

Depends on how your application handles opening other files.

One would think that assuming filetype associations are configured properly in Windows, it should know what application to open .rtf files with (per your example).

In powershell, you could use gc if you're only looking at plaintext data. http://www.ats.ucla.edu/stat/mult_pkg/faq/general/powershell_examples.htm

In Python, you would handle the file as an object, per the example here: https://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files

But if you wanted to launch a specific secondary application to open the file, you might try running an outside program (executable) in python?

Community
  • 1
  • 1
Aaron
  • 1
  • Powershell looks like it might be useful, but the page you pointed me to only shows me user-interactive-level stuff. Really doesn't help me know how to invoke Powershell from my C or C++ application. How would I do that? (I'll use Python if I have to, but I'd rather keep down my external dependencies, they make installation and maintenance of an application rather more complex.) – Joymaker Jan 29 '16 at 23:55