Enumerate uninstall registry key to get displayname & displayversionvalue
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Enumerate uninstall registry key to get displayname & displayversionvalue

  1. #1
    Join Date
    Sep 2010
    Posts
    7

    Enumerate uninstall registry key to get displayname & displayversionvalue

    Hey, I am trying to enumerate the

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall

    registry key and check the displayname & displayversion registry value for all the sub keys under the uninstall key then compare the displayname & displayversion value with a if statement.

    For example if one of the the displayname = "Adobe Flash Player 10 ActiveX" & displayversion = "10.1.82.76" then textbox.text = "Your adobe flash is up to date"


    This is the code I been using to check a specific registry value to see if quicktime 7.67.75.0 is installed i figured it would be best to enumerate the subkeys and check the displayname & displayversion because im checking like 6 programs to see if the version is current.

    Dim quicktime As String
    quicktime = My.Computer.Registry.GetValue _
    ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{EB900AF8-CC61-4E15-871B-98D1EA3E8025}", "DisplayVersion", Nothing)
    quicktime = (quicktime)

    If quicktime = "7.67.75.0" Then quicktime1.Text = " Quicktime 7.67.75.0 is installed" Else quicktime1.Text = " Quicktime 7.67.75.0 is not installed"

    If quicktime = "7.67.75.0" Then quicktime1.ForeColor = Color.Green Else quicktime1.ForeColor = Color.Red


    I'm new to VB any help would be great!!!

    Im using vb 08

  2. #2
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,960

    Re: Enumerate uninstall registry key to get displayname & displayversionvalue

    I don't think that's the best way to do it. Plus, it's just as easy to tell you how to REMOVE programs, which would be against the AUP, in my estimation.

    You can check the version thats running, as well. In task manager...
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Sep 2010
    Posts
    7

    Re: Enumerate uninstall registry key to get displayname & displayversionvalue

    Im not trying to uninstall programs. i'm trying to check the version then display the version in a text box so a user can run the program to see if their software needs updated.

  4. #4
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,960

    Re: Enumerate uninstall registry key to get displayname & displayversionvalue

    This site still exists, but the link changed. This enumerates the registry, but doesn't do much else, but enumerate the data keys, then the value keys.

    Code:
    Const ERROR_NO_MORE_ITEMS = 259&
    Const HKEY_CURRENT_CONFIG = &H80000005
    Const HKEY_LOCAL_MACHINE = &H80000002
    Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
    Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
    Private Declare Function RegEnumKeyEx Lib "advapi32.dll" Alias "RegEnumKeyExA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, lpcbName As Long, ByVal lpReserved As Long, ByVal lpClass As String, lpcbClass As Long, lpftLastWriteTime As Any) As Long
    Private Declare Function RegEnumValue Lib "advapi32.dll" Alias "RegEnumValueA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpValueName As String, lpcbValueName As Long, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
    
    Private Sub Form_Load()
        'KPD-Team 2001
        'URL: http://www.allapi.net/
        'E-Mail: KPDTeam@Allapi.net
        Dim hKey As Long, Cnt As Long, sName As String, sData As String, Ret As Long, RetData As Long
        Const BUFFER_SIZE As Long = 255
        'Set the forms graphics mode to persistent
        Me.AutoRedraw = True
        Me.Print "RegEnumKeyEx"
        Ret = BUFFER_SIZE
        'Open the registry key
        If RegOpenKey(HKEY_LOCAL_MACHINE, "Hardware", hKey) = 0 Then
            'Create a buffer
            sName = Space(BUFFER_SIZE)
            'Enumerate the keys
            While RegEnumKeyEx(hKey, Cnt, sName, Ret, ByVal 0&, vbNullString, ByVal 0&, ByVal 0&) <> ERROR_NO_MORE_ITEMS
                'Show the enumerated key
                Me.Print " " + Left$(sName, Ret)
                'prepare for the next key
                Cnt = Cnt + 1
                sName = Space(BUFFER_SIZE)
                Ret = BUFFER_SIZE
            Wend
            'close the registry key
            RegCloseKey hKey
        Else
            Me.Print " Error while calling RegOpenKey"
        End If
        Me.Print vbCrLf + "RegEnumValue"
        Cnt = 0
        'Open a registry key
        If RegOpenKey(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion", hKey) = 0 Then
            'initialize
            sName = Space(BUFFER_SIZE)
            sData = Space(BUFFER_SIZE)
            Ret = BUFFER_SIZE
            RetData = BUFFER_SIZE
            'enumerate the values
            While RegEnumValue(hKey, Cnt, sName, Ret, 0, ByVal 0&, ByVal sData, RetData) <> ERROR_NO_MORE_ITEMS
                'show data
                If RetData > 0 Then Me.Print " " + Left$(sName, Ret) + "=" + Left$(sData, RetData - 1)
                'prepare for next value
                Cnt = Cnt + 1
                sName = Space(BUFFER_SIZE)
                sData = Space(BUFFER_SIZE)
                Ret = BUFFER_SIZE
                RetData = BUFFER_SIZE
            Wend
            'Close the registry key
            RegCloseKey hKey
        Else
            Me.Print " Error while calling RegOpenKey"
        End If
    End Sub
    Last edited by dglienna; September 17th, 2010 at 08:36 PM.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center