[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 189
  • Last Modified:

Open a text file

How can I open a text file or *.doc file by any default viewer or editor of the computer my program would possibly run ! sorry I only have 13 points left
0
ahTri
Asked:
ahTri
  • 2
1 Solution
 
nietodCommented:
I assume this is for windows?  Look at ShellExecute().
0
 
mbequetteCommented:
I need a little further explanation.  If you want, for instance notepad to open a text file and your program is to control all of this, you can make a win32 CreateProcess call and pass the file name(parameters) and the executable(notepad) is to use.  This will work for other editors as well.  However, I am not sure by your question what you want.  If this is I can give you further explanation with specific code examples.
hope this helps,
mb
0
 
nietodCommented:
ShellExecute() works because you don't have to specify the application.  You just specify the file to be opened and windows finds the application to open it--if possible.
0
 
ahTriAuthor Commented:
thanks Nietod

for mbequette : what I want is to open a file by what ever a default viewer or editor of the host machine, not a specific one to be defined by CreateProcess ! For example a PC that doesnt have Words it would open a .doc file by WordPad or a wordviewer plugin ... thanks though
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now