VB.NET / C # после нахождения установленных имен ПО и пути к приложению - PullRequest
0 голосов
/ 26 февраля 2012

Этот код получает все программное обеспечение, которое имеет запись удаления и путь к приложению. Однако, учитывая, что у меня есть путь к приложению, я не знаю имя основного .exe программного обеспечения. Какие есть способы найти основной .exe найденного приложения?

   'Declare the string to hold the list:
    Dim Software As String = Nothing

    'The registry key:
    Dim SoftwareKey As String = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
    Using rk As RegistryKey = Registry.LocalMachine.OpenSubKey(SoftwareKey)
        'Let's go through the registry keys and get the info we need:
        Dim j As Integer = 0
        For Each skName As String In rk.GetSubKeyNames()
            Using sk As RegistryKey = rk.OpenSubKey(skName)
                Try
                    'If the key has value, continue, if not, skip it:
                    If Not (sk.GetValue("DisplayName") Is Nothing) And Not (sk.GetValue("InstallLocation") Is Nothing) And
                    Not (sk.GetValue("InstallLocation") = "") Then
                        Dim instanceremoved As Boolean = False
                        For Each item As ListViewItem In ListInstalled.Items
                            If item.SubItems.Item(1).Text = sk.GetValue("InstallLocation") Then
                                item.Remove()
                                instanceremoved = True
                            End If
                        Next

                        If instanceremoved = False Then
                            Dim itemAdd As ListViewItem = ListInstalled.Items.Add(sk.GetValue("DisplayName"))
                            itemAdd.SubItems.Add(sk.GetValue("InstallLocation"))

                        End If

                    End If
                    'No, that exception is not getting away... :P
                Catch ex As Exception
                    MsgBox(ex)
                End Try
            End Using
            j = j + 1
        Next
    End Using

1 Ответ

0 голосов
/ 26 февраля 2012

Основной Exe не хранится в реестре, команда удаления сохраняется в ключе UninstallString.

...