All file extension association information is stored in the registry. And if you do a little browsing, it's not terribly difficult to figure out how things work. For machine-wide associations, it all happens in the root of HKEY_CLASSES_ROOT. Manual editing of this stuff gives you ultimate power over your file extensions (albeit tedious). Just create a backup in case you screw things up and want to revert.
Each file association has a subkey called .xyz where xyz is the extension of your file. The (Default) value for that key is set to some arbitrary string. Most applications that register file extensions set it to something human readable. For example, .pdf on my system is set to FoxitReader.Document. There many be other values in this key, but nothing is mandatory except the (Default) value.
For whatever that (Default) value is set to, there will be a corresponding subkey with the same name also in the root of HKEY_CLASSES_ROOT. The (Default) value of this key is essentially the "friendly name" of the file type. This key may also have many subkeys, but the only ones we're interested in are DefaultIcon and Shell.
DefaultIcon as you probably guessed controls the icon for that file type. The (Default) value for this key should be set to the path of the icon file. Or if the icon is in a .exe file, set it to the path of the .exe and include a comma and the icon index at the end of the path. For instance, the FoxitReader.Document DefaultIcon is set to
C:\PROGRA~1\FOXITS~1\FOXITR~1\FOXITR~1.EXE,1
Shell is where you set up all of the "actions" for this file type. For each action you want to define, create a subkey called whatever you want to name the action. Most types have at least one action called open. Within this new action's subkey, create a subkey called Command. The (Default) value of this Command key is basically the command line that runs when this action is clicked/run. For example, the open command on a FoxitReader.Document is
"C:\PROGRA~1\FOXITS~1\FOXITR~1\FOXITR~1.EXE" "%1"
The "%1" argument gets set to the path of the file you ran the action from.
If you've only got one action defined for a given file type, I believe it will be the default action that is run if the file is double clicked. If there are multiple possible actions, you can set which one will be the default by modifying the (Default) value of the Shell key. Just set it to the name of the action you want to be the default.
With all of this said, it's not very efficient to do it all from scratch. It's probably easier to use the built-in tools to get most of the way there and then just tweak the things manually that the tools don't let you do. I should also probably mention that all of this info is based on XP, but I'm almost positive none of it has changed for Vista or Win7.
2Yes, file associations and extensions is one area where Vista/Win7 took a HUGE step back from XP and prior. – eidylon – 2009-08-15T00:29:58.533