VB.NET/C#查找安装的软件名称和应用程序路径后如何查找exe名称
此代码获取所有具有卸载条目和it应用程序路径的软件。但是,由于我有应用程序路径,我不知道该软件的main.exe的名称。有什么方法可以找到找到的应用程序的main.exeVB.NET/C#查找安装的软件名称和应用程序路径后如何查找exe名称,vb.net,list,exe,installed-applications,Vb.net,List,Exe,Installed Applications,此代码获取所有具有卸载条目和it应用程序路径的软件。但是,由于我有应用程序路径,我不知道该软件的main.exe的名称。有什么方法可以找到找到的应用程序的main.exe 'Declare the string to hold the list: Dim Software As String = Nothing 'The registry key: Dim SoftwareKey As String = "SOFTWARE\Microsoft\Windows\Cu
'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
主Exe未存储在注册表中。卸载命令存储在卸载字符串项中。在文件系统的不同位置,不在注册表中是,但是,是否有一些标准的方法来检索已安装软件的主exe名称,或者用户必须自己选择它?您可以搜索所有的exe,但windows不知道它们,除非您想在startmenu中查找,否则它在注册表中只知道如何卸载