我想在系统上检测已安装的游戏并将其显示在列表框中。我认为我能做的最好的事情是扫描注册表的特定部分,并查找与发布者列表匹配的密钥名称。
但我怎么做呢?
我正在尝试这个,但是这显示了所有已安装的程序。
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim regkey, subkey As Microsoft.Win32.RegistryKey
Dim value As String
Dim regpath As String = "Software\Microsoft\Windows\CurrentVersion\Uninstall"
regkey = My.Computer.Registry.LocalMachine.OpenSubKey(regpath)
Dim subkeys() As String = regkey.GetSubKeyNames
Dim includes As Boolean
For Each subk As String In subkeys
subkey = regkey.OpenSubKey(subk)
value = subkey.GetValue("DisplayName", "")
If value <> "" Then
includes = True
If value.IndexOf("Hotfix") <> -1 Then includes = False
If value.IndexOf("Security Update") <> -1 Then includes = False
If value.IndexOf("Update for") <> -1 Then includes = False
If includes = True Then ListBox1.Items.Add(value)
End If
感谢。