Link to home
Start Free TrialLog in
Avatar of protemus
protemus

asked on

Events in COM Server


I have a simple COM object, but I am unable to get its events in a client....

The following lines are the problem in the COM server implementation:

//---------------------------------------------
//  Initialize
//---------------------------------------------
procedure TMyCOMObject.Initialize;
begin
  inherited Initialize;
  FConnectionPoints := TConnectionPoints.Create(Self);
  if AutoFactory.EventTypeInfo <> nil then
    FConnectionPoint := FConnectionPoints.CreateConnectionPoint(
      AutoFactory.EventIID, ckSingle, EventConnect)
  else FConnectionPoint := nil;


The problem is that AutoFactory.EventTypeInfo is nil.... why is this?  How do I make sure my factory knows about my events?
ASKER CERTIFIED SOLUTION
Avatar of Jacco
Jacco
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I thought I had to create a class that implements IMyCOMObjectEvents (which was not possible since only the dispatch interface is in the typelib so I copied this interface stripped disp of dispinterface and added safecall) so I created a new class implementing IDispatch and my new IMyCOMObjectEvents and did all the implementations.

Then I created a MyComObject using CreateOleObject('MyLib.MyComObject ')
Created my event handler object
Connected it to MyComObject using a call to InterfaceConnect
Called TestEvent
But it crashes....
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I registered the DLL using the Delphi menu Register ActiveX library.