This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this 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. The first argument is the literal, quoted, case-sensitive string or character vector 'name'.


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

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


collapse all

Display Control Panel\Mouse values.

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));
mousechar = 

Display the CLSID for mwsampctrl.2, a sample Microsoft COM control used in MATLAB® examples.

ans =

Input Arguments

collapse all

Root key name, specified as a case-sensitive string or character vector.


Subkey name, specified as a string or a character vector. The value is not case-sensitive.

Example: 'control panel\mouse'

Name of value, specified as a string or a character vector. The name is not case-sensitive.

Output Arguments

collapse all

Value names, specified as a cell array of character vectors.

Value of specified name, specified as a character vector if the value retrieved from the registry is a registry string value. If the value is a 32-bit integer, winqueryreg returns the value as an integer of the MATLAB type int32.


  • This function works for the following registry value types only:

    • strings (REG_SZ)

    • expanded strings (REG_EXPAND_SZ)

    • 32-bit integer (REG_DWORD)

See Also

Introduced before R2006a