ArcGIS 10, Delphi and licensing

2433
6
03-18-2011 07:42 AM
MarcusThorand
New Contributor
Hello developer,

we have an standalone application, written in Delphi, which must get a ArcView or a ArcEditor-Licence, to write data in a Geodatabase over COM and ArcObjects.

A license for ArcView exist on the pc

With ArcGIS 9.3.1 we have had no problems to check the active license with

isProductCodeAvailable

and then we initialize the specific product.

But with ArcGIS 10 we always get "0" as return-value (which is not defined by any constant of esriLicenseStatus) for the function isProductCodeAvailable.

I think, we have to bind our Delphi-ComObjects to ArcGIS 10?
But how we can do so, because in our generated .pas Files from the COM-Dll's we find no function for this!

Pehaps there is a developer, who uses Delphi 6 or 7 and can give us a hint for the initial steps to get a licensed ArcObject Connection?

Thanks a lot for any hint,

Marcus
0 Kudos
6 Replies
RichardWatson
Frequent Contributor
In version 10 there are some additional steps that you have to take before you can use ArcObjects.  I think that the function is something like Bind.  Goggle on "arcgis 10 bind license".
0 Kudos
MaxGazuko
New Contributor
Hi!
There's solution:
var
  status: TOleEnum;
  res: HRESULT;
  bool_res:   WordBool;
begin

  verManager := TVersionManager.Create(self);

  i_agVersion := verManager.DefaultInterface as IArcGISVersion;
  res := i_agVersion.LoadVersion(ArcGISVersionLib_TLB.esriArcGISEngine,'10.0',bool_res);

  if (res <> S_OK) then
  begin
    SetError(OLE_ERROR);
    Exit;
  end;
  if (not bool_res) then
  begin
    SetError(NO_VERSION_AVAIL);
    Exit;
  end;

  aoInit := TAoInitialize.Create(self);
  i_aoInit := aoInit.DefaultInterface as IAoInitialize;
  res := i_aoInit.IsProductCodeAvailable(esriSystem_TLB.esriLicenseProductCodeEngineGeoDB, status);
  if (res <> S_OK) then
  begin
    SetError(OLE_ERROR);
    Exit;
  end;
  if (status <> esriSystem_TLB.esriLicenseAvailable) then
    begin
      SetError(NO_LICENSE_AVAIL);
      Exit;
    end
  else
    begin
      res := i_aoInit.Initialize(esriSystem_TLB.esriLicenseProductCodeEngine,
                                      status);
      if (res <> S_OK) then
      begin
        SetError(OLE_ERROR);
        Exit;
      end;
      if (status <> esriSystem_TLB.esriLicenseCheckedOut) then
      begin
        SetError(INIT_FAIL);
        Exit;
      end;
    end;

  MapControl:=TMapControl.Create(Self);


Where
   MapControl:TMapControl;
   verManager: TVersionManager;
   aoInit: TAoInitialize;
   i_aoInit:   IAoInitialize;
   i_agVersion: IArcGISVersion;
and SetError is some function for error handling.
0 Kudos
MarcusThorand
New Contributor
Hello gazuko,

thank's a lot for your reply.

I try to understand your code snipped.

First I generate a lot of tbl-Files from the COM-DLL's of ArcGIS 10 (ex. esriSystem_TBL.pas).
In this files, I look for a function "LoadVersion" or "verManager", but I can't find somthing like this.

Therefore I suppose, that I get compiler errors from Delphi.

In which DLL or _TBL.pas file I can find the LoadVersion-Function?

Greetings
Marcus
0 Kudos
MaxGazuko
New Contributor
Hi, Marcus!

You must import "ArcGISVersion 1.0 Type Library" (Project->Import Type Library) (ArcGIS\bin\ArcGISVersion.dll)

In imported "ArcGISVersionLib_TLB" you will find class "TVersionManager" and interface "IArcGISVersion".

LoadVersion is function of IArcGISVersion interface.

WBR, Max.
0 Kudos
MarcusThorand
New Contributor
Hi Max,

your last hint was the key!
Now it work's perfect.

Only one little hint: I found the DLL "ArcGISVersion.dll" in "c:\Program Files\Common Files\ArcGIS\bin"

But thank's a lot for your help!

Marcus
0 Kudos
IlyaNenashev
New Contributor
One more hint for future searchers:
If not use VersionManager like described in previous message in this thread, any call to CoCreateInstance or other COM initialization function for ArcGIS classes like MapControl or even LicenseControl will be fail with very ugly error CLASS_E_CLASSNOTAVAILABLE = $80040111 = -2147221231

Thanks a lot, gazuko, for You code snippet!
0 Kudos