• Coding
  • How to retrieve file extensions from registry?

Hello geeks,

For some reasons, i want to retrieve a list of All the extensions available on a PC from the registry...
I'll be adding them to a ListBox/ComboBox in C#...

Any suggestions ?
Help is much appreciated :)
Give this a try, although am not sure if its the proper and only way.

HKEY_CLASSES_ROOT ==> Everthing starting with a dot.
what os are you using ? 7 , vista , xp ? , if its 7 i think this can help Control Panel\Programs\Default Programs\Set Associations

from regedit : HKEY_CLASSES_ROOT* ,.386 (etc...) till HKEY_CLASSES_ROOT.ZIPX

now the retrieving process : right click on HKEY_CLASSES_ROOT and choose export , save the file for example 1.reg
then right click on that file and choose edit after that you have many methods like search for . or whatever your aim is , hope that helps
Hey mrmat and Aj_BlaZ,
Thanks for your reply, but here's the problem:

I need to write a C# piece of code to does that automatically for me. I know where to find the list of extensions in My registry and the Control Panel. The program should also work on all other registries.
and just for curiosity, i exported HKEY_CLASSES_ROOT to a .txt file. it took a while to Save/Open the file, but the file was totally useless, and there was no way to retrieve all the extensions from it.

All what i need is to access the computer's registry programatically and retrieve the list of extensions...

Edit: The size of that text file is 114MB. Interesting!!!
That's not interesting, that's just wrong! I remember doing something like this once... I think the normal size of a registry is in the neighborhood or 10-20 megs if I'm not mistaken
Why exporting them to a text file?

All you need is to retrieve the list of all keys in the "HKEY_CLASSES_ROOT" section. Then just filter the extensions. All of these can be done programmatically using C#.

If no one does, i'll post a solution here once am able to.
Here you go...

First add the following to your uses
using Microsoft.Win32;
And use this method
void ListExtensions()
        {

            foreach (string keyname in Registry.ClassesRoot.GetSubKeyNames())
            {
                if (keyname.StartsWith("."))
                {
                    listBox1.Items.Add(keyname);
                }
            }
            

        }
Thanks for the input. Will be testing that in a while. :)