Suppose the scenario where you need to know the local registry root for a running instance of VS, to find out for example a list of registered VS Packages.
The local registry root depends on the registry hive where the VS is running into, so it could be :
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\
Or
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0Exp
Here is the code snippet that does the trick:
string regRoot;
ILocalRegistry3 registry = Package.GetGlobalService(typeof(SLocalRegistry)) asILocalRegistry3;
ErrorHandler.ThrowOnFailure(registry.GetLocalRegistryRoot(out regRoot));
Pablo
The Visual Studio 2008 Shell was just announced. After seeing the screenshots and reading the main features:
-
Faster Development. The Visual Studio Shell accelerates development by providing a base integrated development environment that can host custom tools and programming languages.
-
A Familiar Environment. Developers can build on the Visual Studio platform and provide end users a familiar user interface, speeding the learning curve for both.
-
Optimized for Languages & Tools. Created in response to requests from our partners, the Visual Studio Shell gives you the option of integrating your tools with Visual Studio or creating an isolated, custom-branded application.
I can only say WOW; finally extending VS will be much easier. :)
Meanwhile you can continue using VSIPFactory and of course a version running on top of Visual Studio 2008 Shell will be available in the future. :)
Pablo
When dealing with VS Packages sometimes we need to do some common operations like:
- We want to know if a VS Package is loaded
- We want to load a VS Package
- We want to obtain a VS Package reference
The following snippet shows how to determine if a VS Package is loaded, how to load it and how to obtain a reference to an existing registered VS Package:
IVsShell vsShell = Package.GetGlobalService(typeof(SVsShell)) as IVsShell;
Guid packageGuid = new Guid("20D04F2E-0CA4-4f75-A21B-0DC6BAF9430A");
IVsPackage package;
vsShell.IsPackageLoaded(ref packageGuid, out package);
if(package != null)
{
//Package Loaded
}
else
{
vsShell.LoadPackage(ref packageGuid, out package);
}
Happy VS Extending :)
Pablo