Documentation
¶
Rendered for windows/amd64
Overview ¶
Package registry provides access to the Windows registry.
Here is a simple example, opening a registry key and reading a string value from it.
k, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Windows NT\CurrentVersion`, registry.QUERY_VALUE)
if err != nil {
log.Fatal(err)
}
defer k.Close()
s, _, err := k.GetStringValue("SystemRoot")
if err != nil {
log.Fatal(err)
}
fmt.Printf("Windows system root is %q\n", s)
NOTE: This package is a copy of golang.org/x/sys/windows/registry with KeyInfo.ModTime removed to prevent dependency cycles.
Index ¶
- Constants
- Variables
- func DeleteKey(k Key, path string) error
- func ExpandString(value string) (string, error)
- func LoadRegLoadMUIString() error
- type Key
- func (k Key) Close() error
- func (k Key) DeleteValue(name string) error
- func (k Key) GetBinaryValue(name string) (val []byte, valtype uint32, err error)
- func (k Key) GetIntegerValue(name string) (val uint64, valtype uint32, err error)
- func (k Key) GetMUIStringValue(name string) (string, error)
- func (k Key) GetStringValue(name string) (val string, valtype uint32, err error)
- func (k Key) GetStringsValue(name string) (val []string, valtype uint32, err error)
- func (k Key) GetValue(name string, buf []byte) (n int, valtype uint32, err error)
- func (k Key) ReadSubKeyNames() ([]string, error)
- func (k Key) ReadValueNames() ([]string, error)
- func (k Key) SetBinaryValue(name string, value []byte) error
- func (k Key) SetDWordValue(name string, value uint32) error
- func (k Key) SetExpandStringValue(name, value string) error
- func (k Key) SetQWordValue(name string, value uint64) error
- func (k Key) SetStringValue(name, value string) error
- func (k Key) SetStringsValue(name string, value []string) error
- func (k Key) Stat() (*KeyInfo, error)
- type KeyInfo
Constants ¶
View Source
const ( // Registry key security and access rights. // See https://msdn.microsoft.com/en-us/library/windows/desktop/ms724878.aspx // for details. ALL_ACCESS = 0xf003f CREATE_LINK = 0x00020 CREATE_SUB_KEY = 0x00004 ENUMERATE_SUB_KEYS = 0x00008 EXECUTE = 0x20019 NOTIFY = 0x00010 QUERY_VALUE = 0x00001 READ = 0x20019 SET_VALUE = 0x00002 WOW64_32KEY = 0x00200 WOW64_64KEY = 0x00100 WRITE = 0x20006 )
View Source
const ( // Windows defines some predefined root keys that are always open. // An application can use these keys as entry points to the registry. // Normally these keys are used in OpenKey to open new keys, // but they can also be used anywhere a Key is required. CLASSES_ROOT = Key(syscall.HKEY_CLASSES_ROOT) CURRENT_USER = Key(syscall.HKEY_CURRENT_USER) LOCAL_MACHINE = Key(syscall.HKEY_LOCAL_MACHINE) USERS = Key(syscall.HKEY_USERS) CURRENT_CONFIG = Key(syscall.HKEY_CURRENT_CONFIG) )
View Source
const ( // Registry value types. NONE = 0 SZ = 1 EXPAND_SZ = 2 BINARY = 3 DWORD = 4 DWORD_BIG_ENDIAN = 5 LINK = 6 MULTI_SZ = 7 RESOURCE_LIST = 8 FULL_RESOURCE_DESCRIPTOR = 9 RESOURCE_REQUIREMENTS_LIST = 10 QWORD = 11 )
Variables ¶
View Source
var ( // ErrShortBuffer is returned when the buffer was too short for the operation. ErrShortBuffer = syscall.ERROR_MORE_DATA // ErrNotExist is returned when a registry key or value does not exist. ErrNotExist = syscall.ERROR_FILE_NOT_FOUND // ErrUnexpectedType is returned by Get*Value when the value's type was unexpected. ErrUnexpectedType = errors.New("unexpected key value type") )
Functions ¶
func ExpandString ¶
ExpandString expands environment-variable strings and replaces them with the values defined for the current user. Use ExpandString to expand EXPAND_SZ strings.
func LoadRegLoadMUIString ¶ added in go1.6
func LoadRegLoadMUIString() error