Book a Demo

Author Topic: Problem with Automation Interface after EA startup  (Read 4747 times)

BTurban

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Problem with Automation Interface after EA startup
« on: October 17, 2005, 03:20:01 am »
Hi,
I hope anybody can help me with my problem. ???

I'm using Delphi 2005.

In my project, I'm using an OCX plugin-dll to send events of EA to a main application(exe) via sockets.

In my former versions all code was included into the OCX. But in my new version I encountered several problems
that prevented Delphi from properly creating the OCX.
Now that I have taken out most of the code into an exe, the OCX problem is solved.

But now I have encountered a new problem:
Because my exe also needs to access the EA repository, I just wanted to establish a normal connection to EA via
the automation COM-interface. Usually this should be done by  GetActiveOleObject ('EA.App') ....

NOTE: My intention is that a user opens an EA project as normal and then my application clicks into the opened Repository.

I have tried several way to get the IDualApp interface to furtherly retrieve IDualRepository.

E.G.:
app:=TApp.Create(NIL);
lEA_App  :=app.DefaultInterface;

idisp:= IDispatch(  GetActiveOleObject ('EA.App') );
//now cast iDispatch...

idisp:= IDispatch(  CreateOleObject ('EA.App')  );
//now cast iDispatch...

lEA_App := (idisp as TApp). GetDefaultInterface();

idisp:= CoApp.Create();


The funny thing is, that all these calls work as long as Ea.exe has not been started from outside!
That means as long as I run my exe and EA has not been started, the calls work. But as soon as EA.exe gets
started,
all calls retrieve the exception "coInitialize not called!".

I also tried to retrieve first the IDualApp interface, then start EA.exe. But this just dislocated the problem to the
point, when I tried to retrieve the actual Repository of IDualApp.

Unfortunately, I'm not a COM expert, but I know that coInitialize should be called by the COM-Library for initialization purposes.
My strong guessing is, that when EA.exe gets called, it mixes something up in its provided COM interface?
But of course, it could also be a problem of my code and my ignorance of the details about COM.

Can anybody help me to solve this problem? ???