How To Use Erlang Win32Reg to Read Windows Registry Keys?

Onorio Catenacci

I'm tagging this as both Erlang and Elixir because my sample code is in Elixir but I suspect the answer will involve the Erlang Win32Reg library.

Windows 8.1 x64

Erlang 17.4

Elixir 1.0.3

I do the following from Iex on Windows:

{:ok, handle} = :win32reg.open([:read])
:ok = :win32reg.change_key(handle, :local_machine)

When I do this I get this error:

** (FunctionClauseError) no function clause matching in :win32reg.split_key/3
    (stdlib) win32reg.erl:364: :win32reg.split_key(:local_machine, [], [])
    (stdlib) win32reg.erl:340: :win32reg.parse_relative/2
    (stdlib) win32reg.erl:122: :win32reg.change_key/3

However if I use this code instead:

:ok = win32reg.change_key(handle,'HKEY_LOCAL_MACHINE') 

It works as expected. I tried this same code directly in the werl shell and the result is the same.

1.) Shouldn't :local_machine work the same?

2.) When I change to the HKLM key and do this:

{:ok, sub_keys} = :win32reg.sub_keys(handle)

I get this:

{:ok, ['Software']}

Going by what I see in regedit, there are several other subkeys below the HKLM key. Why aren't they showing up?

I can't easily test this on other versions of Windows so this issue may be specific to Windows 8.x. If that's the case, that's fine; I'm just trying to insure I'm not coding something incorrectly.

Leaf Garland

Looking at the win32reg docs, the aliases you mention are valid but they are strings, as you can use them as elements of a path.

:win32reg.change_key(handle, '\\local_machine\\')

I've also found that you need to give it absolute paths initially, note the slash at the start.

With those changes I was able to see the same nodes as regedit.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Read Registry Keys on different Windows Versions with NSIS

How to read registry keys to output in powershell?

How to edit the registry in Windows 10 (like in Win 7), without having to take ownerships of keys all the time?

How to insert registry entries from a .reg file into 32-bit registry on 64-bit Windows

How to copy registry keys for this?

Erlang: How can I use binary keys / data with eredis?

How to read windows registry data on remote machine using java

How do I read Windows Registry file to check for values? [Python]

How to read the Steam Install Path from the Windows Registry?

How to add or update registry keys?

How to iterate all of the registry keys?

Windows: How can I use the command line to set registry permissions

How to decode a REG_BINARY date from Windows registry?

Windows registry keys that affect shortcuts behavior

Use PowerShell to search for string in registry keys and values

Custom Reg file with keys not present on registry

Creating Registry keys SID REG_BINARY

Read registry value 32 bit?

How add registry keys with CPACK_PACKAGE_INSTALL_REGISTRY_KEY?

How do you use JSONUtility to read an object with hypens in the keys?

How can i use keys to clone, read and write to Github on Ubuntu?

How to get registry keys and values in listview

How to add the same value to multiple registry keys

How to refresh registry keys without reboot?

Need to read registry value from both 32 bit and 64 bit machine Windows machine

How to edit the registry in Windows 7

Windows Registry | how to open .lnk

How to use Spring-Kafka to read AVRO message with Confluent Schema registry?

How to Read Reg_Binary type values in string format from Registry in python