Solved

Problem with RegisterActiveObject

Posted on 2008-10-08
2
843 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month7 days, 10 hours left to enroll

632 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