LoadFromRegistry Method (NamedValues Collection)

             

 

Loads a NamedValues collection from the Registry.

 

Syntax

object.LoadFromRegistry RootKey, SubKey, [Options]

The LoadFromRegistry method syntax has these parts:

Part

Description

object

An object expression that evaluates to an object in the Applies To list.

RootKey

An expression drawn from the pinvRegistryKeyConstants enumeration, as described in Settings. This value gives the root key of the registry entry to load.

SubKey

A string expression, indicating a subkey found below the root given in RootKey.

Options

An optional expression drawn from the pinvRegistryOptions enumeration, as described in Settings.

 

Settings

The settings for RootKey are:

Error

Description

pinvHKEY_CLASSES_ROOT

Load a subkey of HKEY_CLASSES_ROOT.

pinvHKEY_CURRENT_USER

Load a subkey of HKEY_CURRENT_USER.

pinvHKEY_LOCAL_MACHINE

Load a subkey of HKEY_LOCAL_MACHINE.

pinvHKEY_USERS

Load a subkey of HKEY_USERS.

pinvHKEY_PERFORMANCE_DATA

Load a subkey of HKEY_PERFORMANCE_DATA.

pinvHKEY_CURRENT_CONFIG

Load a subkey of HKEY_CURRENT_CONFIG.

pinvHKEY_DYN_DATA

Load a subkey of HKEY_DYN_DATA.

 

The settings for Options are:

Error

Description

pinvNoOptions

Only the given registry key is loaded. This is the default.

pinvIncludeSubkeys

The given registry key, and all its subkeys, are loaded into the NamedValues collection. Each subkey is loaded as a NamedValue whose name is the subkey name, and whose value is a nested NamedValues collection.

 

Remarks

Depending on your operating system, not all the given root keys may exist in the Registry.

A key’s default registry value is loaded as a NamedValue whose Name property is the empty string.

Only registry values of type REG_SZ, REG_DWORD, and REG_EXPAND_SZ are loaded. Values of other registry data types are loaded as Error variants. Registry values of type REG_SZ and REG_EXPAND_SZ are loaded as strings. Registry values of type REG_DWORD are loaded as Long values.

Registry values of type REG_EXPAND_SZ may contain environment variables, which are expanded before loading.

Please exercise caution when Options = pinvIncludeSubkeys. Loading a large Registry hierarchy may take a lot of time.

Trappable Errors

In addition to generic errors (such as Out of Memory), the following errors may occur:

Error

Description

pseACCESSDENIED

The collection cannot be modified because it is frozen; that is, the collection's ReadOnly flag is true.

pseINVALIDOPTIONS

The options argument contains invalid or inconsistent settings.

pseOPENINGREGKEY

A Windows API error occurred when the PI SDK attempted to open the specified registry key. To find out more about the error, examine Err.Description.

pseUNKNOWNREGTYPE

One or more of the values in the specified Registry key is of an unknown registry data type. Those values have been loaded into the NamedValues collection as Error variants whose error code is pseUNKNOWNREGTYPE. This error indicates a problem in the Registry or in Windows, or an incompatibility between the PISDK library and the running version of Windows.

pseUNSUPPORTEDREGTYPE

One or more of the values in the specified Registry key is of a known, but unsupported, registry data type. Those values have been loaded into the NamedValues collection as Error variants whose error code is pseUNSUPPORTEDREGTYPE. This error occurs most frequently with values of type REG_MULTI_SZ or REG_BINARY, which are fairly common in the Registry but which this method does not support.

Enabling Operational Intelligence