How to determine registered version of MATLAB from a C# program?

9 views (last 30 days)
I have multiple versions of Matlab installed on my computer. My application needs to be able to determine which is the active or current version of Matlab (ie. the most recently registered version). I know it has something to do with a registry entry. Thanks.

Answers (1)

Phillip Meyer
Phillip Meyer on 29 Sep 2017
Edited: Walter Roberson on 29 Sep 2017
Looks like I got it. Code is kinda rough but it works.
object line;
string registry_key = @"MATLAB.AutoServer"; //@"MATLAB.AutoServer\CurVer";
using (var baseKey = Microsoft.Win32.RegistryKey.OpenBaseKey(RegistryHive.ClassesRoot, RegistryView.Registry64))
{
using (var key = baseKey.OpenSubKey(registry_key))
{
string foo = key.Name;
string [] bar = key.GetValueNames();
using (var subKey = key.OpenSubKey("CurVer"))
{
line = subKey.GetValue("");
}
}
}

Categories

Find more on Install Products in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!