winqueryreg
Reads a value, or lists the entries, of a key in the Windows registry.
Category: Environment and Settings > System Commands
Syntax
value = winqueryreg(rootkey, subkey, valname)
Reads the registry value valname of the key.
names = winqueryreg('name', rootkey, subkey)
Lists the names of the values and subkeys of the key.
Description
winqueryreg only reads the registry; it never writes. A key or value that does not exist is an error ('Specified key or value does not exist in the registry'). The function exists for Windows only.
Input arguments
rootkey- Root hive:
'HKEY_CLASSES_ROOT','HKEY_CURRENT_USER','HKEY_LOCAL_MACHINE'or'HKEY_USERS'. subkey- Path of the key under the root, with backslashes.
valname- Name of the value to read.
Output arguments
value- The registry value: a character vector for string types, a number for integer types.
names- Cell array of character vectors.
Example
List and read values
key = 'SOFTWARE\Microsoft\Windows NT\CurrentVersion';
names = winqueryreg('name', 'HKEY_LOCAL_MACHINE', key);
disp(class(names))
prod = winqueryreg('HKEY_LOCAL_MACHINE', key, 'ProductName');
disp(class(prod))
Output
cell
char