Visual Studio registry output sample

This simple package demonstrates how Visual Studio registry related information can be accessed and displayed.

Points of Interest:

  • VSXtra provides the VsRegistry static class to access the local registry information of the currently running Visual Studio instance. Using this class you can access important registry keys and information behind those keys.
  • You can directly write to the General pane of the Output window through System.Console.
Package source code:

using System.Runtime.InteropServices;
using Microsoft.VisualStudio.Shell;
using VSXtra;

namespace DeepDiver.OutputVsRegistry
{
  [PackageRegistration(UseManagedResourcesOnly = true)]
  [DefaultRegistryRoot("Software\\Microsoft\\VisualStudio\\9.0")]
  [InstalledProductRegistration(false, "#110", "#112", "1.0", IconResourceID = 400)]
  [ProvideLoadKey("Standard", "1.0", "OutputVsRegistry", "DeepDiver", 1)]
  [ProvideMenuResource(1000, 1)]
  [Guid(GuidList.guidOutputVsRegistryPkgString)]
  public sealed class OutputVsRegistryPackage : PackageBase
  {
  }
}
Command handler source code:

using System;
using System.Runtime.InteropServices;
using System.Linq;
using Microsoft.VisualStudio.Shell;
using VSXtra;

namespace DeepDiver.OutputVsRegistry
{
  [Guid(GuidList.guidOutputVsRegistryCmdSetString)]
  public sealed class CommandGroup: CommandGroup<OutputVsRegistryPackage>
  {
    [CommandId(CmdIDs.cmdidDisplayRegistryValues)]
    public sealed class OutputRegistryHandler: MenuCommandHandler
    {
      protected override void OnExecute(OleMenuCommand command)
      {
        Console.WriteLine("*** Local registry root key: {0}", VsRegistry.LocalRegistryRoot);
        Console.WriteLine("*** List of recent projects:");
        foreach (var item in VsRegistry.RecentProjectsList.OrderBy(k => k.Key))
        {
          Console.WriteLine("    {0}", item.Value);
        }
        Console.WriteLine("*** List of recent files:");
        foreach (var item in VsRegistry.RecentFilesList.OrderBy(k => k.Key))
        {
          Console.WriteLine("    {0}", item.Value);
        }
      }
    }
  }
}
Screenshots:

VsRegistryOutput1.png

Last edited Aug 5, 2008 at 8:13 AM by INovak, version 5

Comments

No comments yet.