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

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.

Réponses (1)

Phillip Meyer
Phillip Meyer le 29 Sep 2017
Modifié(e) : Walter Roberson le 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("");
}
}
}

Catégories

En savoir plus sur Installing Products dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by