Hi Dw.
I'm tryign to change a registrykey on my system but I get this error: ArgumentException was unhandled, The specified RegistryKeyPermissionCheck Value is invalid. Parameter name: mode
here is the line that throws this error:
regKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(Root & Last, True, (Security.AccessControl.RegistryRights.FullControl))
and the rest of the function code is:
Private Function GetRoot(ByVal Adapter As String) As String
Dim regKey As Microsoft.Win32.RegistryKey
Dim i As Integer = 0
Do
Dim Root As String = "SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\"
Dim Last As String = DoPadding(i)
regKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(Root & Last, True, (Security.AccessControl.RegistryRights.FullControl))
Try
Dim cAdapter As String = regKey.GetValue("DriverDesc").ToString()
If cAdapter = Adapter Then
Return Root & Last
End If
Catch
Exit Do
End Try
i += 1
Loop
End Function
This funtion is called after clicking the update button to update the mac address.
Private Sub bt_update_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_update.Click
Dim mac_text As String = m1.Text.ToUpper + ":" & m2.Text.ToUpper + ":" & m3.Text.ToUpper + ".:" & m4.Text.ToUpper + ":" & m5.Text.ToUpper + ":" & m6.Text.ToUpper
If IsOkay() = False Then
Exit Sub
End If
Dim regKey As Microsoft.Win32.RegistryKey
Dim Addr As String = GetRoot(combo_network.SelectedItem.ToString())
regKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(Addr, True)
regKey.SetValue("NetworkAddress", mac_text.ToString.Replace(":", ""))
ShowRestart()
End Sub
I've tried changing all the available access/modificication permissions that are available within that line but still it just throw this error message.
Thank you