MATLAB: Am I unable to access certain registry keys from R2014b 32-bit on a 64-bit Windows Operating System

MATLAB

I am writing a MATLAB function which depends on a third party external application. To determine whether this application is installed, and where, I want to query the Windows registry.
In Window Registry Editor I can clearly see that a key HKEY_LOCAL_MACHINE\SOFTWARE\ThirdPartyApplication\InstallPath exists. But when I try to access this key from MATLAB 32-bit:
winqueryreg('HKEY_LOCAL_MACHINE','SOFTWARE\ThirdPartyApplication','InstallPath')
I receive the following error: ERROR: ??? Error using ==> winqueryreg Specified key is invalid.

Best Answer

Please note that on 64-bit Windows, 32- and 64-bit applications will see different parts of the registry. This is described in detail on the MSDN website:
Further, please note that on 64-bit Windows there are two versions of the Registry Editor so you can actually see which parts can be seen by which applications:
%SystemRoot%\regedit.exe is the 64-bit version which will show the registry as it will be seen by 64-bit applications.
%SystemRoot%\SysWOW64\regedit.exe is the 32-bit version which will show the registry as it can be seen by 32-bit applications.
For the particular example given above you apparently installed the 64-bit version of the third party application which naturally only added itself to the 64-bit part of the registry, which by default, cannot be seen by MATLAB 32-bit. Possible workarounds for this limitation include:
1. Installing a 32-bit version of the third party application which adds itself to the 32-bit part of the registry.
2. Using the attached winqueryreg64 MEX-file which allows 32-bit MATLAB to query the 64-bit part of the registry. The attached MEX-file has been compiled for Windows 32-bit MATLAB R2014b. The syntax for this MEX-file is the same as for WINQUERYREG.