Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Problem with RegisterActiveObject

Posted on 2008-10-08
2
Medium Priority
?
851 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

721 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