Technology Programming

Associate a filetype (extension) with your application

When creating applications, it's often necessary to store information as a file on the hard drive. You may choose to create your own extension and then associate that extension with your application through Windows.

Basically, you need to add two keys to the registry under HKEY_CLASSES_ROOT. Say your extension is ".ext", then the first key you add is the extension itself:

HKEY_CLASSES_ROOT\.ext\

and set the "default" string value of this key to an "internal name" for your file type - for example MyApp.Document:

HKEY_CLASSES_ROOT\.ext\Default = "MyApp.Document"

You then create another key with this name:

HKEY_CLASSES_ROOT\MyApp.Document\

Create a sub-key of this called "shell", a sub-key of *this* called "open" and a further sub-key of "open" called "command". The default value under this key is the location and name of your application followed by "%1" which represents the filename parameter that Windows will pass to your executable:

HKEY_CLASSES_ROOT\MyApp.Document\shell\open\command\Default = "C:\myapp\myapp.exe %1"

You can do this in code with the TRegistry object, or use InstallShield, which can make registry changes for you. I'd advise doing both, in case the user trashes your registry entry.

p.s.
To work with registry from Delphi, read: Delphi and Registry.

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

Delphi tips navigator:
» Label: FocusControl
« Summing multiple selected rows in a DBGrid

Related posts "Technology : Programming"

Differences Between Byte Array Vs. String

Programming

Web Design Company UK/

Programming

Develop A Quality Plan With These Self Help Tips

Programming

TMediaPlayer: What track am I on?

Programming

How You Can Prove Your Expertise

Programming

Furniture Advice And Tips And Also Hardwearing. Property Searching Wonderful

Programming

Web Design Fort Lauderdale Business

Programming

Hire Web Designer and Diminish Development Expenditure

Programming

Web Masters.

Programming

Leave a Comment