This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.


Item from Windows registry


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


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

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

If the value retrieved from the registry is a string, winqueryreg returns a character vector. If the value is a 32-bit integer, winqueryreg returns the value as an integer of the MATLAB® 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.


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 =

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));
ActiveWindowTracking = 0
DoubleClickHeight = 4
DoubleClickSpeed = 830
DoubleClickWidth = 4
MouseSpeed = 1
MouseThreshold1 = 6
MouseThreshold2 = 10
SnapToDefaultButton = 0
SwapMouseButtons = 0

More About

collapse all


This function works only for the following registry value types:

  • strings (REG_SZ)

  • expanded strings (REG_EXPAND_SZ)

  • 32-bit integer (REG_DWORD)

Introduced before R2006a

Was this topic helpful?