Solved

Problem with RegisterActiveObject

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

740 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