Solved

Problem with RegisterActiveObject

Posted on 2008-10-08
2
830 Views
Last Modified: 2012-06-21
I'm trying to get RegisterActiveObject to behave. Doing it the way that's been described here

type TAutoClass = class (TAutoObject,IMyInterface)
private
  Cookie : longint;
public
  procedure Initialize; override;
...
procedure TAutoClass.Initialize;
  begin
    inherited Initialize:
    RegisterActiveObject (Self As IUnknown, Class_MyClass, ActiveObject_Weak, Cookie);
  end;

gives two 'incompatible types', IUnknown/TAutoClass and Ole2.TGUID/System.TGUID.
I can make it compile OK by writing

    RegisterActiveObject (IUnknown(Self), Ole2.TGUID(Class_MyClass), ActiveObject_Weak, Cookie);

but when I actually use the thing something goes drastically wrong and I'm seeing recursive calls
into the initialize routine, the RegisterActiveObject seems to be causing a new Initialize. What basic
mistake am I making here?
0
Comment
Question by:mikrobe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 27

Expert Comment

by:BigRat
ID: 22677142
From Delphi 5 help :-

When creating an OLE automation object (an object derived from the TAutoObject class in the Oleauto unit) the file that defines that object must call Automation.RegisterClass, passing a record of type TAutoClassInfo. The Automation manager then handles all interactions between the automation object and the OLE automation API.


0
 

Accepted Solution

by:
mikrobe earned 0 total points
ID: 22677243
I think the TAutoObject I'm using here is actually the one defined in ComObj. However I do think there is some confusion about which versions of the various pieces involved are being used (hence the confusion about the TGUID type). The Ole2 module was being referenced in my 'uses' (for historical reasons :-) and removing that not only persuaded Delphi to accept the original syntax but also got rid of the inifinite loop in the Initialize routine. No idea what the problem *really* was other than that Delphi was obviously interpreting things the wrong way when Ole2 was in the mix.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question