I thought I would just write a follow up post for my creating an instance of MapInfo COM object series about being able to detect which version of MapInfo the user has installed.
In this blog post I’m going to show some sample code that you can use to find which version/s of MapInfo the user has installed, to allow you to notify which version of MapInfo your application is compatible with.
When you install MapInfo, it creates a key in the registry which stores information for MapInfo like MI version,COM GUID, Access code etc. The key that contains this information is located in:
if we open up the registry and have a look at that key we should be able to see something that looks like this:
In the above picture you can see that professional subkey shows a folder for each version of MapInfo that you have installed, as you can see on my PC I have version 9.5 and 10 installed. Each one of these keys holds the information for that installed version of MapInfo, if we have a look at the information of version 10 it looks something like this:
As you can see the key has all the information about the installed version 10 of MapInfo including Access Code(000000 for demo version),the COM GUID for MapInfo and install path.
Enough talk lets see some code:
This is a little bit of C#3.0 sample code that you can use to detect and display which version of MapInfo the version has installed.
If you don’t want to use LINQ you could use something like this:
Both will output the installed versions to the console:
Now detecting the version is all well and good but you really need to tell the user if they won’t be able to use your application if they are running a version lower then your application was built with.
Something like this would do it:
Of course the above code is pretty rough but it should do the trick.
Hope this helps.