How to enter a field and its value in registry key+vb.net

RIAS
RIAS used Ask the Experts™
on
Hi,
How to enter a field and its value in registry key I am using vb.net windows.
Already have this function
 Public Function SetOtherRegSetting(ByVal Section As String, ByVal RegKeyName As String, ByVal Field As String, ByVal value As String) As String
        Dim RegSection As String
        Dim regKeyObject As RegistryKey
        Dim TempObj As Object = ""
        Dim GetSetOtherRegSetting As String = String.Empty
        GetSetOtherRegSetting = ""
        RegSection = Section & "\" & RegKeyName & "\"
        regKeyObject = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(RegSection)
        If Not regKeyObject Is Nothing Then
            TempObj = regKeyObject.GetValue(Field)
            If Not TempObj Is Nothing Then
                GetSetOtherRegSetting = TempObj.ToString()
                TempObj = Nothing
            End If
        Else
            regKeyObject.CreateSubKey("DevArea", RegistryKeyPermissionCheck.Default)
        End If
        regKeyObject.Close()
        Return GetSetOtherRegSetting
    End Function
RegistrySettings.docx
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2012
Top Expert 2014

Commented:
What is the code doing? Where does it break?

Author

Commented:
The code is retrieving the key value but I dont know how to set it .
Most Valuable Expert 2012
Top Expert 2014
Commented:
You can use SetValue

regKeyObject.SetValue

but you need to specify that you want to open the subkey in write mode.

regKeyObject = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(RegSection, True)

Author

Commented:
Cheers!!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial