2012-04-04 34 views
6

Có rất nhiều thông tin trên mạng về cách phát hiện loại giấy phép Windows và kênh phân phối bằng PID (có thể tìm thấy trong khóa đăng ký HKLM\SYSTEM\Setup\Pid) và ProductID (có thể tìm thấy trong HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion)).Phát hiện kênh phân phối/loại giấy phép Visual Studio

Tuy nhiên, có rất ít thông tin về cách phát hiện loại cấp phép được sử dụng để cài đặt các sản phẩm khác của Microsoft.

Cụ thể, những gì tôi cần xác định là cái nào được cài đặt bằng giấy phép đăng ký MSDN và được cài đặt bằng các loại giấy phép khác.

tôi đã quản lý để tìm thấy một số thông tin về hương vị văn phòng bằng cách phân tích sản phẩm GUID (tìm thấy trong chi nhánh Uninstall registry):

Tuy nhiên, tất cả những bài viết chỉ phân biệt giữa các loại phát hành:

  • 0 Khối lượng giấy phép
  • 1 Bán lẻ/OEM
  • 2 Trial
  • 5 Tải

Bên cạnh đó, tôi không thể tìm thấy bất kỳ thông tin khả thi nào về các sản phẩm khác. Cụ thể, Visual Studio ... (là một trong những tôi quan tâm nhất).

Để làm rõ: Tôi làm không cần để có được một license key (mà tôi đã tìm thấy một số cách phát hiện trong khi tìm kiếm những thông tin tôi cần), quan tâm của tôi là duy nhất trong việc phát hiện những loại loại giấy phép được sử dụng để cài đặt ứng dụng.

Trả lời

2

Ok vì vậy cách duy nhất tôi có thể thấy để làm điều này là sử dụng một công cụ như magicaljellybeans key finder và sau đó có các phím xuất khẩu từ bạn MSDN giấy phép và làm một so sánh.

Chỉ từ phần mềm, tôi khá chắc chắn rằng chúng không được xác định là phiên bản MSDN nhưng nó là giấy phép kích hoạt chúng xác định rằng tôi khá chắc chắn rằng những gì bạn đang yêu cầu là không thể như bạn mô tả nó mà không làm so sánh có nghĩa là bạn cần chìa khóa.

Điều này đặc biệt đúng vì một số sản phẩm trong msdn có và sử dụng "phiên bản bán lẻ" của phần mềm.

+0

đã thử magicjellybean, nó không tìm thấy bất cứ điều gì tôi không thể tìm thấy bản thân mình. tôi có thể tự mình khám phá ProductID và ProductKey cho VS, nhưng điều đó không cho tôi biết loại giấy phép là gì, tiếc là – poncha

+0

vấn đề là, Microsoft có cách xác minh điều đó, nhưng tôi sợ nó được thực hiện thông qua các dịch vụ web của WGA. một tùy chọn cho tôi (tôi cần nó để làm việc ngoại tuyến) – poncha

+2

Tôi đang trao tiền thưởng cho câu trả lời này, mặc dù nó không cung cấp giải pháp tôi cần, tuy nhiên có vẻ như giải pháp ** đúng ** không xuất hiện ở đó và câu trả lời này trông giống như câu trả lời thực tế nhất. – poncha

2

http://blogs.msdn.com/b/heaths/archive/2010/05/04/detection-keys-for-net-framework-4-0-and-visual-studio-2010.aspx

Visual Studio 2010 
The detection keys for Visual Studio are used both to detect if the product is installed and what service pack level is installed. As with previous versions, these keys and values are under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DevDiv\VS\Servicing. 

Key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DevDiv\VS\Servicing\10.0\$(var.ProductEdition)\$(var.LCID) 
Name Install 
Type REG_DWORD (32-bit integer) 
Data 0x00000001 (1) 
The values for $(var.ProductEdition) include the following table. The for other products, this value corresponds to the ProductEdition property in the Property table of the Windows Installer package for that product. The locale IDs for $(Var.LCID) are listed here. 

Visual Studio 2010 Ultimate  VSTSCore 
Visual Studio 2010 Premium  VSTDCore 
Visual Studio 2010 Professional PROCore 
Visual Studio 2010 Shell (Integrated) IntShell 
For Dev10 we have also added detection values to the edition keys so that you do not have to detect every single language for ever edition. 

Key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DevDiv\VS\Servicing\10.0\$(var.ProductEdition) 
Name Install 
Type REG_DWORD (32-bit integer) 
Data 0x00000001 (1) 
These registry keys and values are also used to detect the service pack level. Instead of checking for the Name registry value, check the SP registry value. Ignore SPIndex; Microsoft uses this internally. In addition to the registry keys above, we also set a version-dependent registry value listed below. 

Key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DevDiv\VS\Servicing\10.0 
Name SP 
Type REG_DWORD (32-bit integer) 
Data 0x00000001 (1) 
Keep in mind, however, that as with all shared resources the more shared a resource is the less accurate it may be. This is because there is no version policy for registry values and other resources that do not have versions like text files. If two languages were installed at different servicing pack levels – which is unsupported but possible – the value would be set by the last product to be installed or reinstalled (repaired). 

For more information, see the Visual Studio 2010 detection system requirements. This also includes information to use the CompLocator in your Windows Installer package as an alternative to registry detection. 

http://www.mztools.com/articles/2008/MZ2008003.aspx

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> 
+0

điều này có chứa một số thông tin thú vị thực sự (đặc biệt là phần thứ hai), tuy nhiên, điều này nói về việc nhận được VS api từ một tiện ích (mà tôi không). thông tin này có sẵn ở đâu đó trong hệ thống tệp hoặc đăng ký không? – poncha

+0

Tôi đã +1 câu trả lời này vì nó có một số thông tin thú vị và muốn cảm ơn @Nesim vì nỗ lực này, tuy nhiên tôi đã chấp nhận câu trả lời của krystian và trao tiền thưởng cho anh ấy vì nó phù hợp hơn nhiệm vụ trong tay. – poncha