'从注册表中读信息;
' <param name="p_KeyName">要读取的键值</param>
' <returns>读到的键值字符串,如果失败(如注册表尚无信息),则返回""</returns>
Private Function ReadInfo(ByVal p_KeyName As String)
Dim SoftwareKey As RegistryKey = Registry.LocalMachine.OpenSubKey("Software", True)
Dim CompanyKey As RegistryKey = SoftwareKey.OpenSubKey(m_companyname)
Dim strvalue As String = ""
If CompanyKey Is Nothing Then
Return ""
Dim SoftwareNameKey As RegistryKey = CompanyKey.OpenSubKey(m_softwarename)
If SoftwareNameKey Is Nothing Then
Return ""
Try
strvalue = SoftwareNameKey.GetValue(p_KeyName).ToString().Trim()
Catch ex As Exception
End Try
If strvalue Is Nothing Then
strvalue = ""
Return strvalue
End If
End If
End If
End Function
'将信息写入注册表
'<param name="p_keyname">键名</param>
'<param name="p_keyvalue">键值</param>
Private Sub WriteInfo(ByVal p_keyname As String, ByVal p_keyvalue As String)
Dim SoftwareKey As RegistryKey = Registry.LocalMachine.OpenSubKey("Software", True)
Dim CompanyKey As RegistryKey = SoftwareKey.CreateSubKey(m_companyname)
Dim SoftwareNameKey As RegistryKey = CompanyKey.CreateSubKey(m_softwarename)
SoftwareNameKey.SetValue(p_keyname, p_keyvalue)
End Sub