Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the visual studio 2010 icons for files in solution explorer of Visual Studio 2012

I got access to Visual studio 2012 a couple of days back and I found that the solution explorer is a bit too minimalistic for my taste.
With most icons grey and black , I have to make an extra effort to find out the file that I was looking for.

Is there a way to revert back to 2010 style icons for files ?

like image 488
Shashank Shekhar Avatar asked Oct 06 '22 19:10

Shashank Shekhar


1 Answers

The only "solution" I know if is to uninstall Visual Studio 2012.

The problem comes down to how the icons are registered. When 2012 is installed, all the HKEY_CLASSES_ROOT icon registrations are over-written with 2012. Conceptually you could edit these registrations to "restore" or change the icon. For example, .csproj files are linked to the first icon in the C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC#\VCSPackages\csproj.dll file. You could change that so the icon points to the first icon in C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC#\VCSPackages\csproj.dll instead. A .reg file to set that value could be created to set that value, for example:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\VisualStudio.Launcher.csproj.11.0\DefaultIcon]
@="c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC#\\VCSPackages\\csproj.dll,0

That, when double-clicked, would "restore" the icon to the 2010 icon. But, you'd have to do that for each and every icon you want to "restore".

Update:

I suppose you could write some code to search the registry and replace icons that point to 11.0 files and replace them with 10.0 files. For example:

const string vsDirectory = "c:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\";
int index = vsDirectory.IndexOf("10.0\\", StringComparison.Ordinal);

var keyNames = Registry.ClassesRoot.GetSubKeyNames();
foreach (var name in keyNames.Where(name => name.StartsWith("VisualStudio.Launcher.")))
{
    using(RegistryKey key = Registry.ClassesRoot.OpenSubKey(name+@"\DefaultIcon"))
    {
        if (key == null) continue;
        var value = key.GetValue(null).ToString();
        if (!value.StartsWith(vsDirectory)) continue;
        var sb = new StringBuilder(value);
        var newValue = sb.Replace("10.0", "11.0", index, 4).ToString();
        var elements = newValue.Split(',');
        if (elements.Length <= 0) continue;
        var filename = elements[0];
        if (File.Exists(filename))
        {
            key.SetValue(null, sb.ToString());
        }
    }
}

This particular bit of code only changes class root keys associated with VisualStudio.Launcher and only changes icons that are contained in a file within the "c:\Program Files (x86)\Microsoft Visual Studio 11.0\" directory and have a corresponding 10.0 file. i.e. it won't change the icon of a .cs file. To include those files change "VisualStudio.Launcher." to "VisualStudio." It also assumes icon indexes haven't changed from 10 to 11.

I don't have 10 and 11 installed together, so I didn't test the SetValue of this code. If you use the code, you need to make sure your install is in "c:\Program Files (x86)".

No warranties expressed nor implied. Use at your own risk and only after backing up. If it does what you want, let me know.

like image 178
Peter Ritchie Avatar answered Oct 16 '22 08:10

Peter Ritchie