ATL: instantiating a COM object within its own implementation DLL 
Author Message
 ATL: instantiating a COM object within its own implementation DLL

I have a DLL implementing a COM object. Additionally, I want it to have a
conventional C style interface that makes use of the COM object. The
generated implementation class is called Coscar, the interface Ioscar.

However, attempting a

    Coscar * pOscar = new Coscar();

will not compile since Coscar is abstract.

How can I get hold of an instance of Coscar?

Andreas



Tue, 19 Feb 2002 03:00:00 GMT  
 ATL: instantiating a COM object within its own implementation DLL
You would have to use CComObject<> to actually instantiate the
implementation of classes in ATL.
In your case, it might be something like
CComObject<IOscar>* pOscar = NULL;
CComObject<IOscar>::CreateInstance(&pOscar);

Remember to do
pOscar->Addref();
pOscar->Release(); // If you are not going to pass that interface out
to some other place. BTW: If you have more qs about ATL, try
microsoft.public.vc.activex.templatelib newsgroup.

On Fri, 3 Sep 1999 14:32:25 +0200, "Andreas Huber"

Quote:

>I have a DLL implementing a COM object. Additionally, I want it to have a
>conventional C style interface that makes use of the COM object. The
>generated implementation class is called Coscar, the interface Ioscar.

>However, attempting a

>    Coscar * pOscar = new Coscar();

>will not compile since Coscar is abstract.

>How can I get hold of an instance of Coscar?

>Andreas

Girish Bharadwaj [mvp].
Please do not email queries to me.
Post them in newsgroups.
Thank you.


Tue, 19 Feb 2002 03:00:00 GMT  
 ATL: instantiating a COM object within its own implementation DLL
Thanks a lot (also goes for previous advice), I'll give it a try!



Quote:
> You would have to use CComObject<> to actually instantiate the
> implementation of classes in ATL.
> In your case, it might be something like
> CComObject<IOscar>* pOscar = NULL;
> CComObject<IOscar>::CreateInstance(&pOscar);

> Remember to do
> pOscar->Addref();
> pOscar->Release(); // If you are not going to pass that interface out
> to some other place. BTW: If you have more qs about ATL, try
> microsoft.public.vc.activex.templatelib newsgroup.

> On Fri, 3 Sep 1999 14:32:25 +0200, "Andreas Huber"

> >I have a DLL implementing a COM object. Additionally, I want it to have a
> >conventional C style interface that makes use of the COM object. The
> >generated implementation class is called Coscar, the interface Ioscar.

> >However, attempting a

> >    Coscar * pOscar = new Coscar();

> >will not compile since Coscar is abstract.

> >How can I get hold of an instance of Coscar?

> >Andreas

> Girish Bharadwaj [mvp].
> Please do not email queries to me.
> Post them in newsgroups.
> Thank you.



Tue, 19 Feb 2002 03:00:00 GMT  
 ATL: instantiating a COM object within its own implementation DLL
In an OLE DB Provider if a rowset object is created via
CComObject<Rowset>::CreateInstance inside the Command object, is there
any way to ensure this rowset object will be destructed before the
destruction of the Command object?

David


Quote:

> You would have to use CComObject<> to actually instantiate the
> implementation of classes in ATL.
> In your case, it might be something like
> CComObject<IOscar>* pOscar = NULL;
> CComObject<IOscar>::CreateInstance(&pOscar);

> Remember to do
> pOscar->Addref();
> pOscar->Release(); // If you are not going to pass that interface out
> to some other place. BTW: If you have more qs about ATL, try
> microsoft.public.vc.activex.templatelib newsgroup.

> On Fri, 3 Sep 1999 14:32:25 +0200, "Andreas Huber"

> >I have a DLL implementing a COM object. Additionally, I want it to
have a
> >conventional C style interface that makes use of the COM object. The
> >generated implementation class is called Coscar, the interface
Ioscar.

> >However, attempting a

> >    Coscar * pOscar = new Coscar();

> >will not compile since Coscar is abstract.

> >How can I get hold of an instance of Coscar?

> >Andreas

> Girish Bharadwaj [mvp].
> Please do not email queries to me.
> Post them in newsgroups.
> Thank you.

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


Sun, 24 Feb 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. List of instantiated objects (from within ATL DLL)

2. Instantiating com object in atl service

3. ATL Service instantiating a VB com object

4. accessing ATL object within implementation

5. Using COM objects within COM objects

6. passing COM object pointers to another COM object in ATL

7. Using the CommonDialog ActiveX Control from within an ATL COM dll

8. ATL COM - Passing ATL COM classes through another ATL COM class in the same app

9. How to instantiate a com object?

10. Use of MFC User DLL in ATL COM Object

11. Exception fired during DLL unload in ATL com object

12. using external DLL in ATL COM object

 

 
Powered by phpBB® Forum Software