How do I check out a Spatial Analyst licence with ArcGIS 10 from VB6?

Discussion created by jonathanh on Aug 3, 2011
Latest reply on Dec 8, 2011 by janderson77
We have an ArcGIS extension written in VB6 (I know VB6 is not supported by ESRI - please read on). This calls Spatial Analyst functionality and therefore must check out a Spatial Analyst licence. Over the years ESRI have changed what was required to achieve this, but our last version of the extension was working ok. We have tested this on ArcMap 10 and it works. There is one curious thing though, the test for a Spatial Analyst licence returns False but we try to grab an object anyway and we???ve found this works all the time. It even works when the user has not loaded the Spatial Analyst licence or the Spatial Analyst toolbar in ArcMap (there is a Spatial Analyst licence available of course), so one assumes the code is managing to get a reference to Spatial Analyst somehow.
We have the same code in a VB6 standalone exe, which attempts a similar thing to the ArcGIS extension. The same code tries to check out a Spatial Analyst licence, it returns False, we try to carry on anyway (as in the extension) and then get the error:
-2147221002, ArcGIS product not specified.  You must first bind to an ArcGIS version prior to using any ArcGIS components.

Can anyone give me some example code of how to check out a Spatial Analyst licence from VB6 that works in a standalone VB6 executable? Or is it now impossible (seems unlikely).

Many thanks