winreg

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Rendered for windows/amd64

Overview

Package winreg implements a koanf.Provider for Windows registry and returns a nested config map to provide it to koanf.

Index

Constants

View Source
const (
	RegAuto = iota
	Reg32Bit
	Reg64Bit
)

Determines which branch of the registry will be accessed: 32-bit or 64-bit.

View Source
const (
	CLASSES_ROOT     = registry.CLASSES_ROOT
	CURRENT_USER     = registry.CURRENT_USER
	LOCAL_MACHINE    = registry.LOCAL_MACHINE
	USERS            = registry.USERS
	CURRENT_CONFIG   = registry.CURRENT_CONFIG
	PERFORMANCE_DATA = registry.PERFORMANCE_DATA
)

Reflection of the registry package constants so you don't have to import it explicitly.

View Source
const (
	REG_NOTIFY_CHANGE_NAME       = uint32(0x00000001)
	REG_NOTIFY_CHANGE_ATTRIBUTES = uint32(0x00000002)
	REG_NOTIFY_CHANGE_LAST_SET   = uint32(0x00000004)
	REG_NOTIFY_CHANGE_SECURITY   = uint32(0x00000008)
	REG_NOTIFY_THREAD_AGNOSTIC   = uint32(0x10000000)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Key          registry.Key // Registry key
	Path         string       // A top path in selected key
	DefaultValue string       // The name of the value to which the default key value will be mapped
	MaxDepth     uint         // Maximum subkey reading depth
	Mode         int          // 32/64 bit registry branch, one of RegAuto/Reg32Bit/Reg64Bit constant
}

type WinReg

type WinReg struct {
	// contains filtered or unexported fields
}

func Provider

func Provider(cfg Config) *WinReg

func (*WinReg) Read

func (s *WinReg) Read() (map[string]interface{}, error)

func (*WinReg) ReadBytes

func (s *WinReg) ReadBytes() ([]byte, error)

func (*WinReg) Watch

func (s *WinReg) Watch(cb func(event interface{}, err error)) error

Watch() watches the registry key and triggers a callback when it changes. Due to the nature of the Windows API, you cannot flexibly choose the depth of change tracking. If MaxDepth is not set to 1 in the provider, changes will be monitored to the full depth. If the monitored top-level key is deleted, the function will stop notifications, even if a key with the same name will create again. You must call the Watch() method again.

Jump to

Keyboard shortcuts

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