reg

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package reg is a thin, WOW64-aware wrapper over the Windows registry for the common sysadmin reads and writes that WinBatch did with RegQueryValue / RegSetValue / RegCreateKey / RegExistValue.

The cross-platform surface (the Hive and View types, the function signatures) compiles everywhere; the actual work is Windows-only.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotExist = errors.New("winadmin/reg: key or value does not exist")

ErrNotExist signals a missing key or value.

View Source
var ErrUnsupportedPlatform = errors.New("winadmin/reg: only supported on Windows")

ErrUnsupportedPlatform is returned by every function off Windows.

Functions

func Exists

func Exists(h Hive, path, name string, v View) (bool, error)

Exists reports whether a value exists (the RegExistValue equivalent).

func GetDWord added in v0.2.0

func GetDWord(h Hive, path, name string, v View) (uint32, error)

GetDWord reads a REG_DWORD value as a uint32. A missing key or value returns ErrNotExist (test with errors.Is).

func GetString

func GetString(h Hive, path, name string, v View) (string, error)

GetString reads a REG_SZ value. It returns ("", nil-wrapped not-exist) you can test with errors.Is(err, ErrNotExist).

func GetStrings added in v0.2.0

func GetStrings(h Hive, path, name string, v View) ([]string, error)

GetStrings reads a REG_MULTI_SZ value as a slice of strings (the RegQueryMulSz equivalent). A missing key or value returns ErrNotExist.

func KeyExists added in v0.2.0

func KeyExists(h Hive, path string, v View) (bool, error)

KeyExists reports whether a key exists (the RegExistKey equivalent) — distinct from Exists, which tests a value. Admin checks like "is a reboot pending?" hinge on whether a marker *key* is present, not a value under it.

func SetDWord

func SetDWord(h Hive, path, name string, value uint32, v View) error

SetDWord writes a REG_DWORD value, creating the key if needed.

func SetString

func SetString(h Hive, path, name, value string, v View) error

SetString writes a REG_SZ value, creating the key if needed.

Types

type Hive

type Hive int

Hive selects a root key.

const (
	LocalMachine Hive = iota // HKEY_LOCAL_MACHINE  (@REGMACHINE)
	CurrentUser              // HKEY_CURRENT_USER   (@REGCURRENT)
	ClassesRoot              // HKEY_CLASSES_ROOT
	Users                    // HKEY_USERS
)

type View

type View int

View selects the registry redirection view on 64-bit Windows. Default picks the natural view for the running process; Force32/Force64 are the explicit WOW64 overrides that the old 32-bit WinBatch interpreter could not choose.

const (
	Default View = iota
	Force32
	Force64
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL