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.
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.
Comments