此代码获取具有卸载条目及其应用程序路径的所有软件。但是,鉴于我有应用程序路径,我不知道该软件的主.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
答案 0 :(得分:0)
主Exe不存储在注册表中,uninstall命令存储在UninstallString键中。