Solved

Launch an app from its document-How?

Posted on 1997-08-03
2
163 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 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:

   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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Printing problem 2 81
Dev Express grid collapse 2 39
Tembedded WB animatid gifs not animated on some pcs 2 73
Multi-layered image in FireMonkey 9 18
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

895 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now