Documentation

winqueryreg

Item from Windows registry

Syntax

valnames = winqueryreg('name', 'rootkey', 'subkey')
value = winqueryreg('rootkey', 'subkey', 'valname')
value = winqueryreg('rootkey', 'subkey')

Description

valnames = winqueryreg('name', 'rootkey', 'subkey') returns all value names in rootkey\subkey of Microsoft® Windows® operating system registry to a cell array of strings. The first argument is the literal quoted string, 'name'.

value = winqueryreg('rootkey', 'subkey', 'valname') returns the value for value name valname in rootkey\subkey.

If the value retrieved from the registry is a string, winqueryreg returns a string. If the value is a 32-bit integer, winqueryreg returns the value as an integer of the MATLAB® software type int32.

value = winqueryreg('rootkey', 'subkey') returns a value in rootkey\subkey that has no value name property.

    Note   The literal name argument and the rootkey argument are case-sensitive. The subkey and valname arguments are not.

Examples

Example 1

Get the value of CLSID for the MATLAB sample Microsoft COM control mwsampctrl.2:

winqueryreg 'HKEY_CLASSES_ROOT' 'mwsamp.mwsampctrl.2\clsid'
ans =
   {5771A80A-2294-4CAC-A75B-157DCDDD3653}

Example 2

Get a list in variable mousechar for registry subkey Mouse, which is under subkey Control Panel, which is under root key HKEY_CURRENT_USER.

mousechar = winqueryreg('name', 'HKEY_CURRENT_USER', ...
   'control panel\mouse');

For each name in the mousechar list, get its value from the registry and then display the name and its value:

for k=1:length(mousechar)
   setting = winqueryreg('HKEY_CURRENT_USER', ...
      'control panel\mouse', mousechar{k});
   str = sprintf('%s = %s', mousechar{k}, num2str(setting));
   disp(str)
   end
ActiveWindowTracking = 0
DoubleClickHeight = 4
DoubleClickSpeed = 830
DoubleClickWidth = 4
MouseSpeed = 1
MouseThreshold1 = 6
MouseThreshold2 = 10
SnapToDefaultButton = 0
SwapMouseButtons = 0

More About

expand all

Tips

This function works only for the following registry value types:

  • strings (REG_SZ)

  • expanded strings (REG_EXPAND_SZ)

  • 32-bit integer (REG_DWORD)

Was this topic helpful?