Solved

Opening files from delphi.

Posted on 1998-07-10
3
185 Views
Last Modified: 2010-04-04
Can a delphi program (for win NT and 95) open a file with it asociated application?
Note: the program only konws the name of the file, but it doesn´t know the asociated application.
For example:
Can the program open a "readme.txt" with the notepad, whithout knowing that the notepad is asociated with the extention "txt"?
or
Can the program open a "readme.doc" with the word, whithout knowing that the word is asociated with the extention "doc"?
It is like make a doble click in the windows explorer to open a document...

Juan Pablo.-
0
Comment
Question by:jpussacq
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 1

Expert Comment

by:andrey070798
ID: 1357698
Hi, jpussacq.
In Registry you can find information about programs corresponding to extentions.
After you found the name of the program you can CreateProcess() or WinExec () with name of program and your filename as a parameter.
smth like WinExec ('notepad.exe FileName.txt',  SW_SHOWNORMAL);
  or WinExec (WordPad.exe FileName.doc, SW_SHOWNORMAL);
  If your computer "knows" which extention assosiated to which program you can try to call just WinExec with name of file you want to run (I've checked it in command prompt - works). I've WinNT.
Good luck.
Andrey

0
 
LVL 3

Accepted Solution

by:
KE earned 20 total points
ID: 1357699
Yes !
Use ShellExecute

0
 

Expert Comment

by:subrek
ID: 1357700
Hi, i'm new here ...:)

Have you ever tried the ShellApi.PAS unit ?
There are very useful functions and procedures to e.g. extract an
associated icon with an application which you want to run ...(
and display its associated icon ...)


0

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

695 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