[GIS] Getting MapInfo instance from C# code

cmapinfo

Please sorry for my bad english 🙁

Here is the situation:

I have a .Net DLL written on C#, witch contains windows form.

MapInfo calls function from this DLL witch opens form.

Is there any way to get instance of MapInfo, that called this function? (Not just first opened instance, because i can have multiple opened)

Best Answer

You can use the MapInfo 11.0 OLE Automation Type Library, and doing this:

public Class test 
{
    public static void MethodCalledFromMapInfo()
    {
        MapInfoApplication _MapInfoApplication = (MapInfo.MapInfoApplication)System.Runtime.InteropServices.Marshal.GetActiveObject("Mapinfo.application");
    }
}