Writing binary values to Windows registry
2 posts
• Page 1 of 1
Writing binary values to Windows registry
I'm trying to do write a binary value to Windows registry this way:
but I get this:
As far as I understand, the array I am passing is not considered as a byte array. And, as far as I understand, there is an issue with creating byte arrays: viewtopic.php?f=18&t=172
Are there any other hints on how to write binary Windows registry values, maybe?
⎕USING,←⊂''
hkcu←Microsoft.Win32.Registry.CurrentUser
key←hkcu.CreateSubKey'Software\Foo\Bar'
key.SetValue'Data'(1 2 3 4)Microsoft.Win32.RegistryValueKind.Binary
but I get this:
EXCEPTION: The type of the value object did not match the specified RegistryValueKind or the object could not be properly converted.
key.SetValue'Data'(1 2 3 4)Microsoft.Win32.RegistryValueKind.Binary
∧
As far as I understand, the array I am passing is not considered as a byte array. And, as far as I understand, there is an issue with creating byte arrays: viewtopic.php?f=18&t=172
Are there any other hints on how to write binary Windows registry values, maybe?
-
OSRK - Posts: 17
- Joined: Tue Dec 27, 2016 8:48 am
Re: Writing binary values to Windows registry
Following on from the post that you linked, I was able to write to a binary registry entry as follows:
I then opened the registry editor and could see my new value in Computer\HKEY_CURRENT_USER\Software\Foo\Data
- Code: Select all
⎕using←'' ⍝ Using full paths to show where everything comes from
hkcu←Microsoft.Win32.Registry.CurrentUser
key←hkcu.CreateSubKey⊂'Software\Foo\'
ba←System.Array.CreateInstance(System.Byte)4 ⍝ Create length 4 byte[] array
⎕io←0 ⍝ Match .NET index origin
ba[2]←1 ⍝ Modify byte[] value
ba[⍳4]
0 0 1 0
key.SetValue'Data'(ba)Microsoft.Win32.RegistryValueKind.Binary
I then opened the registry editor and could see my new value in Computer\HKEY_CURRENT_USER\Software\Foo\Data
- RichardP|Dyalog
- Posts: 35
- Joined: Fri Oct 12, 2018 3:05 pm
2 posts
• Page 1 of 1
Return to Windows: GUI, COM/OLE/ActiveX
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group