How can I find out what the default MATLAB COM Automation Server is when I have different versions installed?
4 ビュー (過去 30 日間)
古いコメントを表示
I have multiple versions of MATLAB installed on my system. I would like to interface with MATLAB through the COM Automation Server interface. Is there a way to determine what version is being called by default?
採用された回答
MathWorks Support Team
2013 年 10 月 18 日
The following code will determine what the default server is and if the MATLAB executable that is specified in it exists or not:
function getmatlabdefaultserver()
getdefaultserver('MATLAB.Application');
function getdefaultserver(serverApplication)
if ~exist('serverApplication', 'var')
error('Please specify a server application');
end
try
% Get registry keys.
serverAppCLSID = winqueryreg('HKEY_CLASSES_ROOT', [serverApplication '\CLSID\']);
progId = winqueryreg('HKEY_CLASSES_ROOT', ['CLSID\' serverAppCLSID '\']);
localServer32 = winqueryreg('HKEY_CLASSES_ROOT', ['CLSID\' serverAppCLSID '\LocalServer32\']);
disp(['The default Automation Server for "' serverApplication '" on this machine is:'])
disp(['ProgId: ' progId]);
disp(['LocalServer32: ' localServer32]);
disp(['CLSID: ' serverAppCLSID]);
% Parse server application's path.
serverAppPath = regexpi(localServer32, '.*\.exe', 'match', 'once');
serverAppPath = strrep(serverAppPath, '"', ''); % Remove ".
% Check if executable exists.
if ~isempty(serverAppPath)
if exist(serverAppPath, 'file')
disp(['File exists: ''' serverAppPath '''']);
else
warning(['File does not exist: ' serverAppPath]);
end
end
catch
disp('There was an error while reading the registry.');
end
To register a certain MATLAB version as the default server, execute the following command in the MATLAB Command Window of your desired version, as specified in the related solution 1-3ZJXQR:
!matlab -regserver
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Use COM Objects in MATLAB についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!