1. Home
  2. Computing & Technology
  3. Delphi Programming

How to Run your Application by Double-Clicking on a File (Register Extension)

By , About.com Guide

When creating applications, it is often necessary to store (application related) data on the file system. You may choose to create your own file type (with a *unique* extension) and then associate that extension with your application through Windows. This tells Windows to automatically run your application when a user double-clicks a file in Windows Explorer, for example.

The source code accompanying (download) this tip shows how to:

  • Get Associated application by Extension - if you need to register a file type (extension), be sure that it si not already registered by some other application.
  • Associate a filetype (extension) with your application: description + code
  • Finally, when a user double click a file with "your" extension, Windows will run your application. The ParamStr can be used to get the file being selected.
  • Note: if you want to react when a user drags and drops a file on your (already) running application, or on the TaskBar, you need to handle some special file-drag-drop-accept Windows messages.
Be sure do download the sample application, Delphi functions for all the "steps" are included.

Delphi tips navigator:
» Activate a Running Instance of an Application when a User Openes an Associated File by Extension
« How to Use a Function or a Procedure as a Parameter in another Function

More Delphi Programming Quick Tips
Explore Delphi Programming
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. Delphi 2006 Tips
  7. How to Run your Delphi Application by Double-Clicking on a File (Register a FileType - Extension with Your Program)

©2009 About.com, a part of The New York Times Company.

All rights reserved.