Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Launch an app from its document-How?

Posted on 1997-08-03
2
Medium Priority
?
171 Views
Last Modified: 2010-04-04
Hi,
  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.

Regards,

James Chen
cgcsci@aol.com
0
Comment
Question by:jjchen
2 Comments
 

Accepted Solution

by:
iainmagee earned 300 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:

   REGEDIT
   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)]
   HKEY_CLASSES_ROOT\FMA000_File_assoc\shell\open\ddeexec\application
= 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 =


[Test(%1)


]


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 =
   Myserver

   // 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 =
   MYServer

   // 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 =
   [Test(%1)]



REFERENCES
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 ;-)

Iain.
0
 

Author Comment

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

James
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

927 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