Home arrow Delphi-Kylix arrow Page 2 - Creating an Associator
DELPHI-KYLIX

Creating an Associator


Have you ever wondered how installation programs are able to associate a file extension with a program? Or how when you double click on a MS Word file, Microsoft Word automatically starts up and loads that particular file? Well, in this article I will explain how it is done.

Author Info:
By: Jacques Noah
Rating: 5 stars5 stars5 stars5 stars5 stars / 1
August 09, 2006
TABLE OF CONTENTS:
  1. · Creating an Associator
  2. · Continuing with the code
  3. · How to enable the application to load the file that has been clicked
  4. · The entire code

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Creating an Associator - Continuing with the code
(Page 2 of 4 )

 

If everything is okay, create an instance of the registry object and set the rootkey as in the code below:

"reg := TRegistry.Create;
reg.RootKey := HKEY_CLASSES_ROOT; // Set registry Key
reg.LazyWrite := false;"

Create a new registry key and add the extension, then add the program name  and enable it to accept parameters as follows:

reg.OpenKey('.'+edExt.Text+'shellopencommand', true) then begin
reg.WriteString('', edappname.Text+' %1 ');
reg.CloseKey;

The next section of the procedure associates the extension with a icon, similar to the way MS Word associates all the ".doc" files with its icon. The first icon in an exe is usually the "defaulticon" or icon number "0." The code snippet below is responsible for associating the extension with the icon:

reg.OpenKey('.'+edExt.Text+'DefaultIcon', true);
 {Use the first icon in the executable to display}
 reg.WriteString('', edappname.Text+',0');
 reg.CloseKey;

That's it. Now, after you've associated an extension with an application, the actual application also needs to be able to accept parameters.


blog comments powered by Disqus
DELPHI-KYLIX ARTICLES

- Loading an XML Document into the DOM
- Delphi Wrapper Classes and XML
- Delphi and the DOM
- Delphi and XML
- Internet Access: Client Service
- Finishing the Client for an Internet Access ...
- The Client for an Internet Access Control Ap...
- User Management for an Internet Access Contr...
- Important Procedures for an Internet Access ...
- Server Code for an Internet Access Control A...
- Constructing the Interface for an Internet A...
- Building a Server Application for an Interne...
- Building an Internet Access Control Applicat...
- Client Dataset: Working with Data Packets an...
- Using the Client Dataset in an N-Tiered Appl...

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 10 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials