registryKeyExists: Query for existence of key in registry

View source: R/registry.S

registryKeyExistsR Documentation

Query for existence of key in registry

Description

This function is used to query whether a particular key exists within the registry. It allows one to check before accessing the key and potentially generating an error. This is useful so that we don't have to use numerous try-catch blocks to handle errors, and it also avoids displaying error messages.

Usage

registryKeyExists(path = "", top = .BuiltinKeys[1])

Arguments

path

the path within the registry, relative to the top-level key identified by top, or the entire path.

top

an identifier for one of the built-in top-level keys in which to resolve the path components.

Details

This merely tries to open the key and returns whether this was successful or not.

Value

A logical value indicating whether the key exists and can be read.

Author(s)

Duncan Temple Lang <duncan@wald.ucdavis.edu>

References

http://www.omegahat.org/SWinRegistry

See Also

createRegistryKey getRegistrySubKeyNames getRegistry getRegistryKeyValues

Examples

  # See if R has been registered.
 registryKeyExists("HKEY_LOCAL_MACHINE\\Software\\R-core")

  # See if SNormal is registerd.
  registryKeyExists("SNormal")

  # Check the top-level key HKEY_CLASSES_ROOT exists
  registryKeyExists()

  # This fails on my machine as the Performance information
  # is not registered.
  try(registryKeyExists(top = .BuiltinKeys[8]))

omegahat/SWinRegistry documentation built on July 17, 2022, 7:26 p.m.