String Registry Write
Anyone know why VB.net isnt accepting a standard String Registry Key? I know in VS2005 the way some of the registry mechanics work have change a bit.
Call WriteKey("LicenseKey", "123456789"
PublicFunction WriteKey(ByVal strKey,ByVal strValue)
My.Computer.Registry.LocalMachine.SetValue("HKEY_LOCAL_MACHINE\Software\MySoftware\MyApp\", strKey, strValue)
WriteKey =True
EndFunction
[1031 byte] By [
Sigfuss] at [2007-12-24]
Hi
This will Work fine
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Call WriteKey("LicenseKey", "123456789")
End Sub
Public Function WriteKey(ByVal strKey, ByVal strValue)Dim StartupPath As String = "Software\MySoftware\MyApp\"Dim MyKey As RegistryKey = Registry.LocalMachine.OpenSubKey(StartupPath, True)TryMyKey.SetValue(strKey, strValue)
Return TrueCatch ex As ExceptionReturn FalseEnd TryEnd FunctionYou shouldn't have to include the HKEY_LOCAL_MACHINE part. Try the following
My.Computer.Registry.LocalMachine.SetValue("Software\MySoftware\MyApp", strKey, strValue)
What namespace does RegistryKey appear under?
This gives me an error:
Dim MyKey As RegistryKey = Registry.LocalMachine.OpenSubKey(StartupPath, True)