How do I add a binary registry key to the registry?

I am currently trying to add a key to the registry with:

Dim location As String = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout"

My.Computer.Registry.SetValue(location, "Scancode Map", "00,00,00,00,00,00,00,00,03,00,00,00,00,00,5b,e0,00,00,5c,e0,00,00,00,00", Microsoft.Win32.RegistryValueKind.Binary)

but i get an error when I add the Microsoft.Win32.RegistryValueKind.Binary at the end.

But if i remove it, the key becomes a Reg_SZ instead of a Reg_Binary.

I would also like to know how to delete the key.

Thx



Answer this question

How do I add a binary registry key to the registry?

  • rven

    Where do I put Imports Microsoft.Win32
  • David789

    I assume you want to delete a value, not a key. Try it like this:

    Imports Microsoft.Win32
    ...
    Dim location As String = "SYSTEM\CurrentControlSet\Control\Keyboard Layout"
    Dim key As RegistryKey = Registry.LocalMachine.CreateSubKey(location)
    key.SetValue("Scancode Map", New Byte() {...
    key.DeleteValue("Scancode Map")




  • DeliDaba

    Use a byte array for the data.

    My.Computer.Registry.SetValue(location, "Scancode Map", New Byte() {0,0,0,0,0,0,0,0,&H3,0,0,0,0,0,&H5b,&He0,0,0,&H5c, &He0,0,0,0,0}, Microsoft.Win32.RegistryValueKind.Binary)



  • ldt

    On the first line of the source code file, before any Form or Class declaration.


  • net_starter

    This webpage shows you how to delete the key.


  • daioyayubi

    Could someone plz give me an example for removing a key
  • How do I add a binary registry key to the registry?