Ver versión en español    
 
Home
10 Reasons to use MZ-Tools
MZ-Tools 6.0 for VS.NET
Editions
Features
Online Documentation
MZ-Tools SDK
Download
Purchase
Version History (RSS)  
FAQ & Support
MZ-Tools 3.0 for VB6 & VBA
Features
Online Documentation
Download (freeware)
Donations (Paypal)
Version History (RSS)  
FAQ & Support
User Reviews
Community Place
Contact  
For Add-In Developers
About
   
 
User Testimonials

I'm an avid supporter of MZ-Tools. It's a product I couldn't do without and your level of support is outstanding.

Jan Hyde (Visual Basic MVP)

You will soon wonder how you ever lived without it.

Andy Maggs

More user reviews
 
HOWTO: Detect installed Visual Studio editions, packages or service packs

Author: Carlos J. Quintero (Microsoft MVP) Applies to: Microsoft Visual Studio 2005
Date: February 2008   Microsoft Visual Studio 2008
       
Introduction

This article explains how to detect programmatically (from inside an add-in or package, or from a setup) which Visual Studio versions (2005, 2008), editions (Standard, Professional, etc.) are installed and whether a specific package (subsystem) or service pack is installed or not.

Note: Visual Studio Express editions don't support extensibility (add-ins or packages).

Detecting Visual Studio versions, editions and packages from a setup

  • To detect which Visual Studio versions (2005, 2008, etc.) are installed on a computer from a setup, you can use the following Windows registry entries (or the ones in the next section):
    • For Visual Studio 2005: HKEY_CLASSES_ROOT\VisualStudio.DTE.8.0
    • For Visual Studio 2008: HKEY_CLASSES_ROOT\VisualStudio.DTE.9.0
  • To detect which specific editions (Standard, Professional, Team Edition, etc.) are installed on a computer from a setup, you can use the following Windows registry entries:

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\<version>\Setup\VS\<edition>

    Where <version> can be:
    • For Visual Studio 2005: 8.0
    • For Visual Studio 2008: 9.0

    And <edition> can be:
    • For the Standard Edition: Std
    • For the Professional Edition: Pro
    • For the Team Edition for Software Architects: VSTA
    • For the Team Edition for Software Testers: VSTT
    • For the Team Edition for Software Developers: VSTD
    • For the Team Suite Edition: VSTS
    • For the Premier Partner Edition (2005) or Shell Edition (2008): IDE
    • For the Visual Studio 2005 Tools for the Microsoft Office System: VSTO 

    Furthermore, the "ProductDir" value sets the installation folder.

    Note: the Express Editions don't use the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\ registry key but the following ones:

    • For VB Express: HKEY_LOCAL_MACHINE\Software\Microsoft\VBExpress
    • For VC Express: HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress
    • For C# Express: HKEY_LOCAL_MACHINE\Software\Microsoft\VCSExpress
    • For J# Express: HKEY_LOCAL_MACHINE\Software\Microsoft\VJSExpress
    • For Web Developer Express: HKEY_LOCAL_MACHINE\Software\Microsoft\VWDExpress
  • To detect whether a specific Visual Studio package is installed or not, you need to know ifs unique identifier (GUID) and use the following Windows registry entry:

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\<version>\Packages\<Package Guid>

Detecting Visual Studio versions and editions from an add-in or package

Add-ins and packages can detect the version, edition and installed packages of the IDE where they are loaded:

  • To detect which Visual Studio version a (multi-IDE) add-in is running under, you can use the EnvDTE.DTE.RegistryRoot property, which can return the following values:
    • For Visual Studio 2005: Software\Microsoft\VisualStudio\8.0
    • For Visual Studio 2008: Software\Microsoft\VisualStudio\9.0
  • To detect the edition and subedition of the Visual Studio IDE you can use the IVsShell interface, calling its GetProperty method with the Microsoft.VisualStudio.Shell.Interop.__VSSPROPID2.VSSPROPID_SKUEdition and Microsoft.VisualStudio.Shell.Interop.__VSSPROPID2.VSSPROPID_SubSKUEdition values.

    Note: To get a service from an add-in, see HOWTO: Get a Visual Studio service from an add-in; and to know how to reference an assembly from the GAC (such as Microsoft.VisualStudio.Shell.Interop.dll), see HOWTO: Reference a Visual Studio assembly in the GAC from an add-in.

    The returned results are not well documented but some values are provided in the following sample add-in:

    Imports System
    Imports Microsoft.VisualStudio.CommandBars
    Imports Extensibility
    Imports EnvDTE
    Imports System.Runtime.InteropServices
    Imports Microsoft.VisualStudio.Shell.Interop
    Imports System.Windows.Forms

    <ComVisible(True), ComImport(), Guid("6D5140C1-7436-11CE-8034-00AA006009FA"), _ InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)> _ Friend Interface IServiceProvider <PreserveSig()> _ Function QueryService(<InAttribute()> ByRef guidService As Guid, _ <InAttribute()> ByRef riid As Guid, <OutAttribute()> ByRef ppvObject As IntPtr) As Integer End Interface Public Class Connect Implements IDTExtensibility2 Private Enum SKUEdition SKUEdition_None = 0 SKUEdition_Express = 500 SKUEdition_Standard = &H3E8 SKUEdition_Professional = &H7D0 SKUEdition_AcademicProfessional = &H834 SKUEdition_AcademicStudent = &H834 SKUEdition_AcademicStudentMSDNAA = &H898 SKUEdition_AcademicEnterprise = &H8FC SKUEdition_Book = &H960 SKUEdition_DownloadTrial = &H9C4 SKUEdition_Enterprise = &HBB8 End Enum Private Enum SubSKUEdition SubSKUEdition_None = &H0 SubSKUEdition_VC = &H1 SubSKUEdition_VB = &H2 SubSKUEdition_CSharp = &H4 SubSKUEdition_Architect = &H8 SubSKUEdition_IDE = &H10 SubSKUEdition_JSharp = &H20 SubSKUEdition_Web = &H40 SubSKUEdition_TeamEditionDevelopers = &H80 End Enum Public Function GetService(ByVal serviceProvider As Object, ByVal type As System.Type) As Object Return GetService(serviceProvider, type.GUID) End Function Public Function GetService(ByVal serviceProvider As Object, ByVal guid As System.Guid) As Object Dim objService As Object = Nothing Dim objIServiceProvider As IServiceProvider Dim objIntPtr As IntPtr Dim hr As Integer Dim objSIDGuid As Guid Dim objIIDGuid As Guid objSIDGuid = guid objIIDGuid = objSIDGuid objIServiceProvider = CType(serviceProvider, IServiceProvider) hr = objIServiceProvider.QueryService(objSIDGuid, objIIDGuid, objIntPtr) If hr <> 0 Then System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(hr) ElseIf Not objIntPtr.Equals(IntPtr.Zero) Then objService = System.Runtime.InteropServices.Marshal.GetObjectForIUnknown(objIntPtr) System.Runtime.InteropServices.Marshal.Release(objIntPtr) End If Return objService End Function Public Sub OnConnection(ByVal Application As Object, ByVal ConnectMode As Extensibility.ext_ConnectMode, _
    ByVal AddInInst As Object, ByRef custom As System.Array) _
    Implements Extensibility.IDTExtensibility2.OnConnection Dim objDTE As DTE Dim objService As Object Dim objIVsShell As IVsShell Dim objValue As Object = Nothing Dim eSKUEdition As SKUEdition Dim eSubSKUEdition As SubSKUEdition Select Case ConnectMode Case ext_ConnectMode.ext_cm_AfterStartup, ext_ConnectMode.ext_cm_Startup objDTE = DirectCast(Application, DTE) objService = GetService(objDTE, GetType(IVsShell)) objIVsShell = CType(objService, IVsShell) If objIVsShell.GetProperty(__VSSPROPID2.VSSPROPID_SKUEdition, objValue) = 0 Then eSKUEdition = CType(objValue, SKUEdition) MessageBox.Show(eSKUEdition.ToString) End If If objIVsShell.GetProperty(__VSSPROPID2.VSSPROPID_SubSKUEdition, objValue) = 0 Then eSubSKUEdition = CType(objValue, SubSKUEdition) MessageBox.Show(eSubSKUEdition.ToString) End If End Select End Sub Public Sub OnAddInsUpdate(ByRef custom As System.Array) _
    Implements Extensibility.IDTExtensibility2.OnAddInsUpdate End Sub Public Sub OnBeginShutdown(ByRef custom As System.Array) _
    Implements Extensibility.IDTExtensibility2.OnBeginShutdown End Sub Public Sub OnDisconnection(ByVal RemoveMode As Extensibility.ext_DisconnectMode, _
    ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnDisconnection End Sub Public Sub OnStartupComplete(ByRef custom As System.Array) _
    Implements Extensibility.IDTExtensibility2.OnStartupComplete End Sub End Class
  • To detect whether a specific Visual Studio package is installed or not, you can use the IsPackageInstalled method of the IVsShell interface, which receives the Guid of the package.

Detecting installed Visual Studio Service Packs

Visual Studio uses the following Windows registry entries to track the installed service packs for the several versions (2005, 2008), editions (Standard, Professional, etc.) and languages (English, Spanish, etc.):

HKEY_LOCAL_MACHINE\Software\Microsoft\DevDiv\VS\Servicing\<version>\<edition>\<localeId>

where <version> and <edition> where explained in a previous section of this article and <localeId> is 1033 for English, 3082 for Spanish, etc.

For example, when Visual Studio 2005 Team Edition for Developers has SP1 installed, the value of the "SP" registry entry of HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DevDiv\VS\Servicing\8.0\VSTD\1033 is set to 1.

To know the service at general level (without taking into account the edition and language) you can use the "SP" registry entry under the registry key:

HKEY_LOCAL_MACHINE\Software\Microsoft\DevDiv\VS\Servicing\<version>

Related Articles

Go back to the 'Resources for Visual Studio .NET extensibility' section for more articles like this

MZ-Tools 6.0 for Visual Studio .NET

You can code, design, locate code and document your apps much faster using VB.NET, C#, C++ or Visual J#:

Buy MZ-Tools Now Download MZ-Tools Demo

   Top