Click here to Skip to main content
12,552,909 members (56,662 online)
Rate this:
Please Sign up or sign in to vote.
See more: VS2005 VB Visual-Studio VB.NET , +
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")     
    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))
                If Not regKey.GetValue("DisplayName") = "" Then
                    If regKey.GetValue("DisplayName").ToString = name Then
                        Return regKey.GetValue("InstallLocation").ToString
                    End If
                End If
            Catch ex As Exception
            End Try
            i += 1
        End While
        Return ""
    End Function

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 | Mobile
Web01 | 2.8.161021.1 | Last Updated 10 Jul 2012
Copyright © CodeProject, 1999-2016
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