Solved

Launch an app from its document-How?

Posted on 1997-08-03
2
166 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
[X]
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
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

Industry Leaders: 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

Suggested Solutions

Title # Comments Views Activity
code issue 8 183
How to call a form that is in a DLL  from an application? 13 86
TEMBEDDEDWB how can i change its user agent ? 8 83
Delphi, TImage, Png 2 19
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…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

735 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