Click here to Skip to main content
13,139,773 members (43,963 online)
Rate this:
 
Please Sign up or sign in to vote.
I tried this code for finding the location of the installation folder during uninstallation from Add/remove programs. But when i am clicking on the program to uninstall in add/remove programs
the entry from the registry edit is removed and then coming to unistall overwritten method.
so always the the displaynme in the registry is not found. how do i resolve this.

Public Overrides Sub Uninstall(ByVal savedState As System.Collections.IDictionary)
        Dim regKey As RegistryKey = Registry.LocalMachine.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Uninstall\")
        Dim location As String = FindByDisplayName(regKey, "Myapp")     
        MyBase.Uninstall(savedState)
    End Sub
    Private Function FindByDisplayName(ByVal parentKey As RegistryKey, ByVal name As String) As String
 
        Dim nameList As String() = parentKey.GetSubKeyNames()
        Dim i As Integer = 0
        While i < nameList.Length
            Dim regKey As RegistryKey = parentKey.OpenSubKey(nameList(i))
            Try
                If Not regKey.GetValue("DisplayName") = "" Then
                    If regKey.GetValue("DisplayName").ToString = name Then
                        MsgBox("found")
                        Return regKey.GetValue("InstallLocation").ToString
                    End If
                End If
            Catch ex As Exception
               
            End Try
            regKey.Flush()
            i += 1
        End While
        Return ""
    End Function


thanks
SK
Posted 9-Jul-12 19:35pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web04 | 2.8.170915.1 | Last Updated 10 Jul 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100