Solved

Open a text file

Posted on 1999-01-27
4
181 Views
Last Modified: 2010-04-02
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
Comment
Question by:ahTri
  • 2
4 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 10 total points
ID: 1185285
I assume this is for windows?  Look at ShellExecute().
0
 

Expert Comment

by:mbequette
ID: 1185286
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
 
LVL 22

Expert Comment

by:nietod
ID: 1185287
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
 

Author Comment

by:ahTri
ID: 1185288
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question