Board index » delphi » call CoInitializeSecurity in ActiveX Control

call CoInitializeSecurity in ActiveX Control

I converted a VCL component to a ActiveX control using D4.  In the
create method, the CoInintilaizeSecurity is called.  It works fine
(returns S_OK) as a VCL component. However, when the ActiveX control is
used, it returns RPC_E_TOO_LATE.  I am sure this is because the D4's
wrapper called this function before my object is created.  Does anybody
know if there is a work around?  I did run DcomCnfg without success.
Thanks.

J. Wang

 

Re:call CoInitializeSecurity in ActiveX Control


John Wang ??? a ???? <378E039C.1074E...@nordson.com> ...

Quote
>I converted a VCL component to a ActiveX control using D4.  In the
>create method, the CoInintilaizeSecurity is called.  It works fine
>(returns S_OK) as a VCL component. However, when the ActiveX control is
>used, it returns RPC_E_TOO_LATE.  I am sure this is because the D4's
>wrapper called this function before my object is created.  Does anybody
>know if there is a work around?  I did run DcomCnfg without success.

No chance. The reason is: security initialization should be done after
CoInitialize is called and BEFORE any OLE or COM object created. You OCX
can't control the order in which the hosting application creates COM
objects. It can create some other objects before your OCX will be
initialized so it will be too late to initialize security. Moreover I could
guess that it will be too late even your object is the first COM object to
be created. You can check it if your host application is written with Delphi
that is you can control the order in which objects are created.

Be happy.

Alexey Dynnikov <al...@chat.ru>
http://members.tripod.com/~aldyn
http://al.irt.ustu.ru/~aldyn/
http://www.chat.ru/~aldyn/
SvCom - The Joy of Services

Quote
>Thanks.

>J. Wang

Other Threads