MATLAB: Do I receive an “unknown type” error when using the WINQUERYREG function

MATLAB

When I execute:
val = winqueryreg('HKEY_CLASSES_ROOT', '.mat', '(Default)')
I receive the error
??? Cannot query value of unknown type.
even though the type of this value, REG_SZ, is supported by the WINQUERYREG function.

Best Answer

This error can be produced by attempting to read a value whose type is not supported by WINQUERYREG, but it can also be produced when
1. The value is unset, or
2. The name specified is invalid
The latter case often occurs when referring to the default value for a key. This value is nameless, so the third argument to WINQUERYREG should be omitted:
val = winqueryreg('HKEY_CLASSES_ROOT', '.mat')