Главная страница | назад





Article #17881: Executing and application by extention.

 Question and Answer Database

FAQ2881D.txt   Executing and application by extention.
Category   :Windows API
Platform    :All
Product    :All 32 bit  

Question:
How can I execute the application that is associated with a file
extension?


Answer:
Use the ShellAPI function ShellExecute().

Example:

uses ShellAPI;

procedure TForm1.Button1Click(Sender: TObject);
var
  DocFileName : string;
  DocFileDir : string;
begin
  DocFileName := 'C:\DownLoad\somefile.htm';
  DocFileDir := ExtractFileDir(DocFileName);
  ShellExecute(Form1.Handle,
               nil,
               pChar(DocFileName),
               nil,
               pChar(DocFileDir),
               SW_SHOWNORMAL);
end;


7/16/98 4:31:28 PM
 

Last Modified: 01-SEP-99