Launch an app from its document-How?

Posted on 1997-08-03
Last Modified: 2010-04-04
  Could someone please explain to me how to execute an application by double-clicking on a document file it created. The launched application should then open the document file. In other words, what do I need to do to link a program and its documents so that I can open the document in Windows file manager by double-clicking on the document's icon? This seems to be a standard with Windows applications, but I can't find any info on how to do it with Delphi (I'm using D1)Any help would be greatly appreciated.


James Chen
Question by:jjchen
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

iainmagee earned 100 total points
ID: 1340399
In win95 or NT4 file associations are stored in the registry. If your program has limited circulation, then the simplest (and safest!) way of registering your data type is by adding the details manually in Explorer. To do this you just select 'Options' from the 'View' menu in Explorer, then select the 'File types' tab. You can then use 'New Type' button to create a new association type and link it to your application.

However if you're distributing your software on a larger scale and have an installation routine, then it will be necessary to have the installation automatically add the relevant details to the registry. The MSDN gives two ways of doing this. The following extract is what it says:

----------------->>>>>>>>>>>>>>>>>>>>>>>>>>> From MSDN

You can also set the associations programmatically. This is useful when setting up your application on other machines. You would provide this functionality through your installation program. The first way to do this (the simplier method) is to use regedit to merge the changes from a file. The syntax for this is:

   regedit <filename>.reg

An example of a <filename>.reg is:

   HKEY_CLASSES_ROOT\.riy = FMA000_File_assoc
   HKEY_CLASSES_ROOT\FMA000_File_assoc = File_assoc
   HKEY_CLASSES_ROOT\FMA000_File_assoc\shell\open\command = fileasso.EXE
   HKEY_CLASSES_ROOT\FMA000_File_assoc\shell\open\ddeexec = [Open(%1)]
= Myserver
   HKEY_CLASSES_ROOT\FMA000_File_assoc\shell\open\ddeexec\topic = system
   HKEY_CLASSES_ROOT\FMA000_File_assoc\shell\print\command = fileasso.EXE
   HKEY_CLASSES_ROOT\FMA000_File_assoc\shell\print\ddeexec = [Open(%1)]

HKEY_CLASSES_ROOT\FMA000_File_assoc\shell\print\ddeexec\application = MYServer
   HKEY_CLASSES_ROOT\FMA000_File_assoc\shell\print\ddeexec\topic = System
   HKEY_CLASSES_ROOT\FMA000_File_assoc\shell\print\ddeexec\ifexec =



In the program, you can also add keys to the registry by using the registry APIs. The developer needs to add the following keys to the registration database:

   // Your extensions.
   HKEY_CLASSES_ROOT\.riy = FMA000_File_assoc

   //File type name.
   HKEY_CLASSES_ROOT\FMA000_File_assoc = File_assoc

   // Command to execute when application is not running or dde is not
   // present and Open command is issued.
   HKEY_CLASSES_ROOT\FMA000_File_assoc\shell\open\command = fileasso.EXE

   // DDE execute statement for Open.
   HKEY_CLASSES_ROOT\FMA000_File_assoc\shell\open\ddeexec = [Open(%1)]

   // The server name your application responds to.
   HKEY_CLASSES_ROOT\FMA000_File_assoc\shell\open\ddeexec\application =

   // Topic name your application responds to.
   HKEY_CLASSES_ROOT\FMA000_File_assoc\shell\open\ddeexec\topic = system

   // Command to execute when application is not running or dde is not
   // present and print command is issued.
   HKEY_CLASSES_ROOT\FMA000_File_assoc\shell\print\command = fileasso.EXE

   // DDE execute statement for Print.
   HKEY_CLASSES_ROOT\FMA000_File_assoc\shell\print\ddeexec = [Open(%1)]

   // The server name your application responds to.
   HKEY_CLASSES_ROOT\FMA000_File_assoc\shell\print\ddeexec\application =

   // Topic name your application responds to.
   HKEY_CLASSES_ROOT\FMA000_File assoc\shell\print\ddeexec\topic = System

   // DDE execute statement for print if the application is not already
   // running. This gives the options for a an application to Run, Print
   // and Exit.
   HKEY_CLASSES_ROOT\FMA000_File assoc\shell\print\ddeexec\ifexec =

Windows SDK Programmers Reference, Volume 1, chapter 7, Shell Library or Books Online.
Window 3.1 SDK Help file, Registration Database, Shell Library Functions.
Win32 Programmers Reference, Volume 2, chapter 52, Registry and Initialization Files or Books Online.


I have to admit this looks a little daunting, but my money's on the 2nd method - it seems the most straightforward, though I haven't really tested either method in a production environment.

Hope this helps, and your registry survives ;-)


Author Comment

ID: 1340400
  Thanks for your help. This will get me started, although there might be more to it to have it completely working for me.


Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month11 days, 15 hours left to enroll

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question