From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!

Class (inherits from Object)

Creates and manages registry items on Windows.

FolderCount fa-lock-32.png Parent fa-lock-32.png
KeyCount fa-lock-32.png Path fa-lock-32.png
AddFolder Item
Child KeyType
DefaultValue Name
Delete Value

Constructor(copy as RegistryItem)

Constructor(path as String, create as Boolean)


The Value method returns valid information for expandable strings, binary and multi-strings. In the case of expandable strings, the string is automatically expands for you and returns it as a string. It supports getting and setting 64-bit values. The default value may also be 64-bit.

In the case of multi-strings, you are passed back a string that is Chr(0)-delimited. You can use the String.Split function to get the individual parts, like this:

part = regValue.Split(Encodings.UTF8.Chr(0))

where part is a String array.

In the case of a binary value, a MemoryBlock is returned. You cannot currently set an expandable string, or a multistring. To set a binary string, please pass in a MemoryBlock.

Sample Code

This code displays the registry entries for the current Windows version:

// Get a registry key
Var reg As New RegistryItem("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", False)

Var lines() As String

// now we look on all values on this key
For i As Integer = 0 To reg.KeyCount - 1
Var name As String = reg.Name(i)
Var value As Variant = reg.Value(i)
lines.Add(name + " -> " + value)

// and display them
Var s As String
s = String.FromArray(lines, EndOfLine)

See Also

RegistryAccessErrorException error.