• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 188
  • Last Modified:

Opening files from delphi.

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
jpussacq
Asked:
jpussacq
1 Solution
 
andrey070798Commented:
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
 
KECommented:
Yes !
Use ShellExecute

0
 
subrekCommented:
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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