Execute a file according to its extension (As the Windows Explorer)  

Send By: Q3 Team
Web : www.q3.nu
Email: dlib@q3.nu
Date: 15/09/99

Tip accessed 577 times


In example, to open a *.htm with the default web explorer, to open a *. mp3 with the WinAmp, to open
a .ZIP with the WinZip, etc...

We can make it very easily using the Api function ShellExecute.

For example, if we want to show a html file with a web browser:

  • Add 'ShellApi' in the uses of your form, and execute this:


    Form1.Handle is the handle to the form. If your form's name is otherwise... you change it.

    Inside the PChar () you can put a string variable without problems, that is to say, you could make:


    The function recognizes the extensions defined in the Explorer of Windows, and she calls to the
    corresponding program according to the extension of the file.

    Updated at 16/08/99, since I had forgotten to put ' Add ShellApi in the uses of your form'