func ReadMultiStringValue(keypath, valuename string) ([]string, error) {
	p, err := stripHKey(keypath)
	if err != nil {
		return nil, err
	}
	k, err := openKey(p, registry.QUERY_VALUE)
	if err != nil {
		return nil, err
	}
	defer k.Close()
	vs, _, err := k.GetStringsValue(valuename)
	if err != nil {
		if err == registry.ErrNotExist {
			return nil, ErrValueNotExist
		}
		return nil, fmt.Errorf("unable to read multi-string (REG_MULTI_SZ) registry value [%s -> %s]: %v", p, valuename, err)
	}
	return vs, nil
}
ReadMultiStringValue reads a REG_MULTI_SZ value from the given registry path.
package regutil
import (
	"errors"
	"fmt"
	"path/filepath"
	"strings"
	"golang.org/x/sys/windows/registry"
)
const hkeyPrefix = `HKEY_LOCAL_MACHINE\`
var ErrKeyNotExist = errors.New("regutil: registry key does not exist")
var ErrValueNotExist = errors.New("regutil: registry value does not exist")
func VerifyPath(configurationPath string) error {
	if !strings.HasPrefix(configurationPath, hkeyPrefix) {
		return fmt.Errorf("invalid path [%s], only registry paths starting with %s are supported", configurationPath, hkeyPrefix)
	}
	return nil
}
func stripHKey(keypath string) (string, error) {
	if err := VerifyPath(keypath); err != nil {
		return "", err
	}
	return filepath.Clean(keypath[len(hkeyPrefix):]), nil
}
func openKey(keypath string, access uint32) (registry.Key, error) {
	k, err := registry.OpenKey(registry.LOCAL_MACHINE, keypath, access)
	if err != nil {
		if err == registry.ErrNotExist {
			return k, ErrKeyNotExist
		}
		return k, fmt.Errorf("unable to open registry keypath [%s]: %v", keypath, err)
	}
	return k, nil
}
func CreateKeyIfNotExist(keypath string) error {
	p, err := stripHKey(keypath)
	if err != nil {
		return err
	}
	key, _, err := registry.CreateKey(registry.LOCAL_MACHINE, p, registry.QUERY_VALUE)
	if err != nil {
		return err
	}
	defer key.Close()
	return nil
}
func WriteBinaryValue(keypath, valuename string, content []byte) error {
	p, err := stripHKey(keypath)
	if err != nil {
		return err
	}
	k, err := openKey(p, registry.SET_VALUE)
	if err != nil {
		return err
	}
	defer k.Close()
	err = k.SetBinaryValue(valuename, content)
	if err != nil {
		return fmt.Errorf("unable to write binary (REG_BINARY) registry value [%s -> %s]: %v", keypath, valuename, err)
	}
	return nil
}
func ReadBinaryValue(keypath, valuename string) ([]byte, error) {
	p, err := stripHKey(keypath)
	if err != nil {
		return nil, err
	}
	k, err := openKey(p, registry.QUERY_VALUE)
	if err != nil {
		return nil, err
	}
	defer k.Close()
	s, _, err := k.GetBinaryValue(valuename)
	if err != nil {
		if err == registry.ErrNotExist {
			return nil, ErrValueNotExist
		}
		return nil, fmt.Errorf("unable to read binary (REG_BINARY) registry value [%s -> %s]: %v", p, valuename, err)
	}
	return s, nil
}
func WriteStringValue(keypath, valuename string, content string) error {
	p, err := stripHKey(keypath)
	if err != nil {
		return err
	}
	k, err := openKey(p, registry.SET_VALUE)
	if err != nil {
		return err
	}
	defer k.Close()
	err = k.SetStringValue(valuename, content)
	if err != nil {
		return fmt.Errorf("unable to write string (REG_SZ) registry value [%s -> %s]: %v", keypath, valuename, err)
	}
	return nil
}
func ReadStringValue(keypath, valuename string) (string, error) {
	p, err := stripHKey(keypath)
	if err != nil {
		return "", err
	}
	k, err := openKey(p, registry.QUERY_VALUE)
	if err != nil {
		return "", err
	}
	defer k.Close()
	s, _, err := k.GetStringValue(valuename)
	if err != nil {
		if err == registry.ErrNotExist {
			return "", ErrValueNotExist
		}
		return "", fmt.Errorf("unable to read string (REG_SZ) registry value [%s -> %s]: %v", p, valuename, err)
	}
	return s, nil
}