Registry类提供在运行 Windows 的计算机上的注册表中找到的标准根项集。 注册表是一个存储设备,包含有关应用程序、用户和默认系统设置的信息。例如,应用程序可以使用注册表来存储在应用程序关闭后需要保留的信息,并在应用程序重新加载时访问那些同样的信息。例如,可以存储颜色首选项、屏幕位置或窗口大小。通过将信息存储在注册表中的不同位置,可以针对每个用户来控制这些信息。
Dim rk As RegistryKey = _ Registry.LocalMachine.OpenSubKey("Software\Microsoft\Office", True)
' Get the data from a specified item in the key. Dim s As String() = rk.GetSubKeyNames()
Dim blnExcel As Boolean = False '本机是否安装Excel Dim excelVer As String 'Excel的版本号
For num As Integer = 0 To s.Length - 1 Select Case s.GetValue(num) Case "11.0", "9.0", "8.0", "5.0", "4.0", "3.0" 'Excel各个版本号 Dim rk1 As RegistryKey = _ Registry.LocalMachine.OpenSubKey("Software\Microsoft\Office\" & s.GetValue(num) & "\Excel", True) If Not (rk1 Is Nothing) Then blnExcel = True excelVer = s.GetValue(num) Exit Select Exit For End If End Select Next 用RegistryKey类读写注册表是否十分简便呢?