2
votes

I need to write a new value to the registry. I have come stuck at the following code because what i can add is a standard key and i need to place a new decimal value to a DWORD key (aposed to a hexadecimal value)

{Dim wsh wsh = CreateObject("WScript.shell") wsh.regwrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\Explorer\NoDrives\dword", "789")}

1

1 Answers

0
votes

I'd be using something like:

Imports Microsoft.Win32

Sub SetNoDrives(value As Integer)
    Dim RegPath As String = "SOFTWARE\Microsoft\Windows\CurrentVersion\policies\Explorer"
    Using Key As RegistryKey = Registry.LocalMachine.OpenSubKey(RegPath)
        Key.SetValue("NoDrives", value, RegistryValueKind.DWord)
    End Using
End Sub