Documentation ¶
Overview ¶
Package registry
Optimized copy from sys/windows/registry to work with Crypt.
Index ¶
- Constants
- Variables
- func DeleteKey(k Key, s string) error
- type Key
- func (k Key) Close() error
- func (k Key) DeleteValue(n string) error
- func (k Key) GetBinaryValue(s string) ([]byte, uint32, error)
- func (k Key) GetIntegerValue(s string) (uint64, uint32, error)
- func (k Key) GetStringValue(s string) (string, uint32, error)
- func (k Key) GetStringsValue(s string) ([]string, uint32, error)
- func (k Key) GetValue(s string, b []byte) (int, uint32, error)
- func (k Key) ReadSubKeyNames(n int) ([]string, error)
- func (k Key) ReadValueNames(n int) ([]string, error)
- func (k Key) SetBinaryValue(n string, v []byte) error
- func (k Key) SetDWordValue(n string, v uint32) error
- func (k Key) SetExpandStringValue(n, v string) error
- func (k Key) SetQWordValue(n string, v uint64) error
- func (k Key) SetStringValue(n, v string) error
- func (k Key) SetStringsValue(n string, v []string) error
- func (k Key) Stat() (*KeyInfo, error)
- type KeyInfo
Constants ¶
const ( 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) PERFORMANCE_DATA = Key(syscall.HKEY_PERFORMANCE_DATA) )
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.
const ( TypeString = 1 TypeExpandString = 2 TypeBinary = 3 TypeDword = 4 TypeDwordBigEndian = 5 TypeStringList = 7 TypeQword = 11 )
Registry value types.
Variables ¶
var ( // ErrNotExist is returned when a registry key or value does not exist. ErrNotExist = syscall.ERROR_FILE_NOT_FOUND // ErrShortBuffer is returned when the buffer was too short for the operation. ErrShortBuffer = syscall.ERROR_MORE_DATA // ErrUnexpectedSize is returned when the key data size was unexpected. ErrUnexpectedSize = xerr.Sub("unexpected key size", 0x10) // ErrUnexpectedType is returned by Get*Value when the value's type was // unexpected. ErrUnexpectedType = xerr.Sub("unexpected key type", 0xD) )
Functions ¶
Types ¶
type Key ¶
type Key uintptr
Key is a handle to an open Windows registry key.
Keys can be obtained by calling OpenKey.
func CreateKey ¶
CreateKey creates a key named path under the open key.
CreateKey returns the new key and a boolean flag that reports whether the key already existed.
The access parameter specifies the access rights for the key to be created.
func OpenKey ¶
OpenKey opens a new key with path name relative to the key.
It accepts any open key, including CURRENT_USER and others, and returns the new key and an error.
The access parameter specifies desired access rights to the key to be opened.
func (Key) DeleteValue ¶
DeleteValue removes a named value from the key.
func (Key) GetBinaryValue ¶
GetBinaryValue retrieves the binary value for the specified value name associated with the open key. It also returns the value's type.
If value does not exist, GetBinaryValue returns ErrNotExist.
If value is not BINARY, it will return the correct value type and ErrUnexpectedType.
func (Key) GetIntegerValue ¶
GetIntegerValue retrieves the integer value for the specified value name associated with the open key. It also returns the value's type.
If value does not exist, GetIntegerValue returns ErrNotExist.
If value is not DWORD or QWORD, it will return the correct value type and ErrUnexpectedType.
func (Key) GetStringValue ¶
GetStringValue retrieves the string value for the specified value name associated with the open key. It also returns the value's type.
If value does not exist, GetStringValue returns ErrNotExist.
If value is not SZ or EXPAND_SZ, it will return the correct value type and ErrUnexpectedType.
func (Key) GetStringsValue ¶
GetStringsValue retrieves the []string value for the specified value name associated with an open key k. It also returns the value's type.
If value does not exist, GetStringsValue returns ErrNotExist.
If value is not MULTI_SZ, it will return the correct value type and ErrUnexpectedType.
func (Key) GetValue ¶
GetValue retrieves the type and data for the specified value associated with the open key.
It fills up buffer buf and returns the retrieved byte count n. If buf is too small to fit the stored value it returns an ErrShortBuffer error along with the required buffer size n.
If no buffer is provided, it returns true and actual buffer size and the value's type only.
If the value does not exist, the error returned is ErrNotExist.
GetValue is a low level function. If value's type is known, use the appropriate Get*Value function instead.
func (Key) ReadSubKeyNames ¶
ReadSubKeyNames returns the names of subkeys of key k.
The parameter controls the number of returned names, analogous to the way 'os.File.Readdirnames' works.
func (Key) ReadValueNames ¶
ReadValueNames returns the value names in the key.
The parameter controls the number of returned names, analogous to the way 'os.File.Readdirnames' works.
func (Key) SetBinaryValue ¶
SetBinaryValue sets the data and type of a name value under key k to value and BINARY.
func (Key) SetDWordValue ¶
SetDWordValue sets the data and type of a named value under the key to the supplied value and DWORD.
func (Key) SetExpandStringValue ¶
SetExpandStringValue sets the data and type of a named value under the key to the supplied value and EXPAND_SZ.
The value must not contain a zero byte.
func (Key) SetQWordValue ¶
SetQWordValue sets the data and type of a named value under the key to the supplied value and QWORD.
func (Key) SetStringValue ¶
SetStringValue sets the data and type of a named value under the key to the supplied value and SZ.
The value must not contain a zero byte.
func (Key) SetStringsValue ¶
SetStringsValue sets the data and type of a named value under the key to the supplied value and MULTI_SZ.
The value strings must not contain a zero byte.