Enumerating Registry Values in Go (Golang)
I'm trying to enumerate over a list of values in the Windows registry
using Go, but I'm running into some trouble. I've tried two approaches:
using both the Go-provided syscall library to call into RegEnumValue, as
well as using a Windows API wrapper by lxn. In both cases, I'm having the
same issue. This is the code I'm using (which is currently using the win
library from lxn):
var root win.HKEY
rootpath, _ := syscall.UTF16PtrFromString("HARDWARE\\DEVICEMAP\\SERIALCOMM")
fmt.Println(win.RegOpenKeyEx(win.HKEY_LOCAL_MACHINE, rootpath, 0,
win.KEY_READ, &root))
var name_length uint32 = 72
var name *uint16
var key_type uint32
var lpData *byte
var lpDataLength uint32 = 72
var zero_uint uint32 = 0
fmt.Println(win.RegEnumValue(root, zero_uint, name, &name_length, nil,
&key_type, lpData, &lpDataLength))
win.RegCloseKey(root)
In this case, RegEnumValue always returns code 87, which MSDN's only
explanation is "The parameter is incorrect."
Does anyone have any ideas that can point me in the right direction for this?
No comments:
Post a Comment