Hi guys,
I've created a very small automation object (using delphi 7). It works at all, but I have problem to register it in the running object table so that I can use getActiveOleObject function to retrieve a running instance of the server. The problem is that the Initialize and Destroy events doensn't fire.
EDIT: I've just noted that the initialize is fired when I create the application via createOleObject in an client application.
EDIT2: Download the sample projekt here
Here's the sourcecode:
unit mycomserver;
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
ComObj, ActiveX, server_TLB, StdVcl, dialogs;
type
Tmyserver = class(TAutoObject, Imyserver)
private
FROTCookie: Longint;
public
procedure Initialize; override;
destructor Destroy; override;
protected
procedure hello; safecall;
end;
implementation
uses ComServ;
procedure Tmyserver.Initialize;
begin
inherited;
//Register object in ROT
showmessage('Why the init event doesnt fire?');
OleCheck(RegisterActiveObject(Self, CLASS_myserver, ActiveObject_Weak, FROTCookie))
end;
destructor Tmyserver.Destroy;
begin
// unegister object in ROT
showmessage('And destroy event also doesnt fire...');
OleCheck(RevokeActiveObject(FROTCookie, nil));
inherited;
end;
procedure Tmyserver.hello;
begin
showmessage('hello its me the comserver');
end;
initialization
showmessage('com server init works...');
TAutoObjectFactory.Create(ComServer, Tmyserver, Class_myserver,
ciMultiInstance, tmApartment);
end.