Solved

Open a text file

Posted on 1999-01-27
4
178 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

861 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now