Associations Editor Associations Editor
home Student Projects no local find frame, full screen Google search web for topic jump to footer translate with Babelfish by Roedy Green ©1996-2008 Canadian Mind Products
This essay is about a suggested student project in Java programming. This essay gives a rough overview of how it might work. It does not describe an actual complete program. I have no source, object, specifications, file layouts or anything else useful to implementing this project. Everything I have to say to help you with this project is written below. I am not prepared to help you implement it; I have too many other projects of my own.

I do contract work for a living, which could include writing a program such as this. However, I don’t do people’s homework for them. That just robs them of an education.

You have my full permission to implement this project any way you please.

In Windows 95/98/ME/NT/W2K/XP/W2K3 you can associate a given file extension with a program or programs to process it. The editor that comes with Windows is clumsy for three reasons:
  1. You can’t see the extensions themselves, just the preposterous external names that Microsoft and their ilk have assigned to them.
  2. When you go to set up an extension, you must find it by name, not by extension. If you set up an extension that already exists, your work is discarded. You can’t even sort them alphabetically by name or extension.
  3. To set up DLE links you must know mysterious commands that no human has a right to know.
So the first order of business is to get the extensions named back to something sensible, possibly beginning with the extension itself. That might be sufficient. If you want to go further, here is what to do:
  1. Allow you to sort by name or extension.
  2. When you switch an association to a different program, don’t discard the information about how to set up the DLE to the first one, in case you ever want to restore it.
  3. Set up some DLE links for common programs automatically. All you need do is select the program from a list of likely candidates.
  4. Wherever possible don’t force the user to go chasing all over the disk to find the apps. Find them for him and let him select from a list.
Just how is this information stored in the registry? Each extension is associated with four different names. Ironically, even though an extension in practice can have more than one use, the only name that is guaranteed unique in the registry is the extension. Starting with the extension you can find the three other names. For example consider the extension ( .exe ), you can find the MIME type ( application/x-msdownload ) and the internal name ( exefile ). With the internal name, you have a link to find the external name ( application ) and the various associated actions (e.g. open ) for the applications. The invisible internal name is the glue between the extension and the set of actions (descriptions of how the associated applications launch). It is actually somewhat simpler than it looks from casual observation of the registry with regedit . This entire information is duplicated in HKEY_CLASSES_ROOT and HKEY_LOCAL_MACHINE\SOFTWARE\Classes\ in Microsoft’s usual scheme of redundant inheritance.

Starting with Windows 2000, class registration and file extension information is stored even more redundantly under the HKEY_CURRENT_USER\Software\Classes key as well, ironically with the intent of making the registry more compact. The HKEY_LOCAL_MACHINE\Software\Classes key contains default settings that can apply to all users on the local computer. The HKEY_CURRENT_USER\Software\Classes key contains settings that apply only to the interactive user. The HKEY_CLASSES_ROOT key provides a view of the registry that merges the information from these two sources. See the Microsoft Documentation.

How Windows Stores Extension Associations
Name Example Where Defined Where Referenced
Extension .exe HKEY_CLASSES_ROOT\.exe none
Internal Name exefile HKEY_CLASSES_ROOT\exefile(Default) HKEY_CLASSES_ROOT\.exe
Mime Type application/x-msdownload HKEY_CLASSES_ROOT\.exe(Content Type) none
External Name Application HKEY_CLASSES_ROOT\exefile(Default) none
Action open HKEY_CLASSES_ROOT\exefile\shell\open none
Trace a few examples to get the idea. There are many exceptions to the general rules. Just search the registry for relevant strings to find the many places associations are recorded. Some entries, such as exefile, are marked non-editable via the Disk Explorer. Experiment editing some unimportant extension. Registry editing in general is delicate brain surgery. If you screw up the registry you won’t be able to boot your system to restore from a backup. Further even if you could boot, you can’t restore the registry file since it is in use! Restoring it requires special techniques. See backup. Simon Cooke has posted some code that modifies the icons of script files to a warning icon and changes the default action from run to edit in notepad. See registry for hints on tools to use.

The second half of this project is work out a replacement for the extension scheme, something that might be used in a sane OS, such as ROS. The associations must be much simpler, secure and automatic than in Windows.

Every file has a unique type, similar to MIME, but properly unique, more like Apple’s file type registering scheme. IANA would likely oversee it. Vendors can also create new private file types within their single registered DNS domain, without needing to centrally register them. (In contrast, the same extension in Windows may be used for several totally unrelated formats, e.g. *.doc )

Vendors can register their applications to handle given file types. They can’t unregister other vendors. The originator of a file type must provide a comb program. This studies the file and decides if it is logically consistent. ROS invokes the comb any time two different vendors operate on the same file. In addition, a vendor may supply his own comb that protects him from rival vendors mucking up the file layouts. ROS also uses the combs when it has nothing better to do to ensure file integrity.

When an application is activated/installed, the OS adds that application to the right click menus on all the files it can process. It does not highjack any current application’s associations. If the user starts to mainly use the new program, its will percolate up the menu. It works by a lazy MRU (most-recently used) ordering scheme so that the menu order does not change frequently. The user can freeze menus or manually reorder them.

Users never manually create associations or break them. They merely temporarily hide them from their menus.

In ROS, the associations are self healing. When it has nothing better to do, the OS does a level 1 diagnostic, monitoring their integrity and automatically repairs them if they become damaged.

You might attempt to retrofit some of these features into Windows by maintaining a robust parallel associations database that is used to repair the Windows one.

Ziff Davis has one available with source called ContextEdit. It does not deal with the OpenWithList and PersistentHandler options in the registry. It does not give you the ability to order the open, edit, print etc. options. And finally it is full of technobabble e.g. "%1" DDE, &Edit. It needs a veneer put on it so that it could be used by an ordinary human. It presumes you already know how to edit the registry directly, and this primarily a tool to make it easier by finding the parts for you.

associations java glossary entry
extensions
fileinfo.net: database of file extensions
Filext.com: database of file extensions, MIME types, and identifying signatures
MIME
registry

CMP_homejump to top
CMP logo
feedback Please email your feedback for publication, errors, omissions, broken/redirected link reports
and suggestions to improve this page to Roedy Green : feedback email
made with CSS
HTML Checked!
ICRA ratings logo
mindprod.com IP:[65.110.21.43]
Your face IP:[38.103.63.18] The information on this page is for non-military use only.
You are visitor number 11. Military use includes use by defence contractors.
You can get a fresh copy of this page from: or possibly from your local J: drive (Java virtual drive/Mindprod website mirror)
http://mindprod.com/project/association.html J:\mindprod\project\association.html