Tweak your computer with registry hacks, Part 2: The Classes Root (in a bit more detail)

It has been long time since I posted part 1 in the registry hacks series, and I hope you read it 10 times like you were suppose to. After much thought I’ve decided that I’ll continue the posts on registry hacks by talking about the Classes Root. Now, for those of you who forgot what the Classes Root is, go and read part 1. If you decide not to, though, (hey, it’s your computer’s funeral, not mine) here is a quick reminder: the Classes Root is the “drive” in the registry that contains information about how to handle files types such as what name, what context menu to show, what icon to show, what to do when double clicking it, etc.

When you open up the Classes Root you’ll see a huge list of extensions starting with *:

If you scroll down a bit further, you’ll notice that soon the list of extensions end – after the extensions starting with .z – and the registry keys are no longer extensions, but rather they are the definitions for the extensions:

To make it easier to work with multiple different extensions that are really the same file type, like JPG and JPEG, Microsoft set it up so that you can create a definition and then link it to each different extensions. To put it in an analogy, the extension is the house address while the definition is the actual house. Keep in mind the difference between extensions and definitions and the relationship between them because that is really important.

Clicking on any of the extensions will reveal some values:

The only two we care about is (Default) and Content Type: (Default) is the name of the definition for that extension, while Content Type is the MIME type that web developers are probably familiar. Only the (Default) value is required for a key, though if the file does have a MIME, it’s not a bad idea for it to have Content Type also.

For every name present in the (Default) value for an extension, there is a corresponding definition key. For example, for the .png extension shown in the screenshot above, there is a pngfile definition:

This definition controls some key aspects for the file extension it is connected to, such as what the file type is called, the icon used by default, and what items appear in the right-click context menu for that file type. In this case, for definitions, (Default) is the name of the file type, like PNG Image (see above screenshot), Microsoft Word Document, or Video File.  It can be any string, and yes spaces are allowed.

Under the definition key, there are a few sub keys:

The two we are interested in are DefaultIcon and shell:

  • DefaultIcon is exactly what it sounds like – controls what is the icon that will appear by default for the file extension the definition is connected to. The (Default) value is the location of the icon to show in Windows for that file type:

For this (Default) value, you are allowed to either point it to the location of an icon file (i.e.  C:\Icons\icon.ico) or the location of an icon embedded in an executable or a DLL (i.e. C:\Windows\System32\url.dll,0).

  • Shell contains a list of the items that appear in the right-click context menu for the associated file extension:

Not all the items you see when you click on a file are here; this list only contains items added specifically for this file type (as opposed to be global), like Open or Print. For each item there is a sub key with an internal name of the item, as you can see from the screenshot above. Each key’s (Default) value is the text shown to the user in the right-click context menu:

The name of the registry key and the (Default) value may be, and probably are, the same, except the key cannot have any spaces; they can be different too, though.

Under each item’s key there is another key called command:

(Default) for command is the command that is run when the item is clicked on (usually double left-click, but will vary depending on your computer settings). For example, as you can see in the above screenshot, clicking on Edit for a Word Document opens Microsoft Word: “C:\Program Files\Microsoft Office\Office12\WINWORD.EXE” /n /dde. The /n and /dde can be considered command line parameters – they give Windows special instructions on how to execute the command in question. Often times you may also find a %1 at the end of the command string. When you click on a menu item, Windows looks at the command, and replaces the %1 in the command string with the file, so if you are opening C:\text.txt and the command is C:\MyProgram.exe “%1”, Windows launches C:\MyProgram.exe “C:\text.txt”.

That is really all I have to say about the Classes Root for now. Keep in mind this is only a basic view of the Classes Root (yes, I know you advanced techies out there must be thinking – “he skipped over so many things”) but for our purposes it is good enough. Get to know the Classes Root well and next time I’ll show off some really cool stuff.

A quick thank you to PC Magazine’s Neil J. Rubenking for showing me this – thanks Neil!

Share this post

  • Samuel

    @JW Cool: Unfortunately life is what happened, luckily I’ve started to have more free time lately and I hope to soon have a continuation of this series out.

    @Ben: A thought, thanks!

  • Ben

    Maybe you also have a ‘.reg’ file of Registry tweaks you find useful & worth sharing? That would be greatly appreciated.

  • Ben

    Maybe you also have a ‘.reg’ file of Registry tricks you find useful & worth sharing? That would be greatly appreciated.

  • JW Cool

    Looking forwaard to part 3 or 4 etc… but it seems end up here since Samuel’s reply posted on May 21,2010
    It’s been 2 years, what happens ??

  • Jyo

    Just went through parts 1 and 2, and had to read slowly because of all these new concepts, but I learned a lot nonetheless. Great job!

  • Samuel

    @OldElmerFudd: Not to do something….I don’t think thats in my vocabulary! LOL.

    On second though, I’ll the final part a useful applications article on how to use the hacks.

    I think i might just do that, just to be safe and all….

  • OldElmerFudd

    @Samuel: It’s been my impression that you’ve tackled this subject as much to help users know what not to do, as much as anything else. Bill3 has a good idea, though. At some point, useful registry tweaks (such as customizing or adding context menu options) might be very helpful to many of the readers.
    Something else that you might consider is a reminder to back up the registry in every installment. 8-)

  • Samuel

    @Bill3: Thanks an interesting idea, I’ll think about putting that into the next part, 2.5

  • Bill3

    Dear Samuel,
    excellent tutorial, but it would have been helpful, if you had explained the objective of the knowledge, and few examples of how you can use it.
    Regards Bill3.

  • OldElmerFudd

    @Ashraf: Sounds like you’re a born tweaker of things yourself! 8-)

  • Ashraf

    @Rajesh: It wasn’t me that wrote it.

  • Rajesh

    Thanks Ashraf for this knowledge base article. I am eagerly waiting for you next article.

  • Ashraf

    @OldElmerFudd: That is my fault, not Samuel’s – I changed his example so it would correspond with screenshots.

  • OldElmerFudd

    Samuel – Very nice exposition, even if necessarily brief. I hope you’ll have time for more about Classes after such a good beginning.
    One observation: In the Word section, you didn’t mention which version the examples illustrated. Office 12 is the original name for Office 2007. The example doesn’t quite match two of my machines that are running Office 2003, but the differences are minor. It might help your readers in future installments if that sort of identification was included.

  • greg

    Really need to read several times and follow this.

  • howard

    Samuel,  thank you.
    Leaving a note here so that I can follow the thread……

  • http://- Jeanjean

    Thank you for all this useful information.
    I look forward to following.

  • Richard

    It will be a long time before I understand this post. My comment is posted so I receive all the follow up comments