Board index » cppbuilder » Are there smart Pointers in BCB??

Are there smart Pointers in BCB??

Hi

Is there an equivalent of _com_ptr_t (MSVC) in BCB4??

I am retrieving an interface from a TVariant, and I currently have to get
the IDispatch and do a Query Interface on it. IS there a quicker way??

Simon

 

Re:Are there smart Pointers in BCB??


I think std::auto_ptr is pretty smart. (#include <memory>)

Re:Are there smart Pointers in BCB??


You have full ATL arsenal to use at BCB4 (CComPtr etc.).

Something like this should do wath you need:
TVariant    Var;

CComQIPtr<IOleObject, &IID_IOleObject> pIF(Var);

ATL functions are documented at MSDN.

Re:Are there smart Pointers in BCB??


Simon,

In addition to the other posts, I'd like to add TComInterface<> (see
VCL\UTILCLS.H).

For example,

TComInterface<IMyInterface, &IID_IMyInterface> p;

p = Server->SomeProperty;

If SomeProperty is a IUnknown*, IDispatch*, DelphiInterface<SomeInterface>,
TVariant or TComInterface<IAnotherInterface>, the assignment operator will
automatically do a QueryInterface behind the scene. You can then simply do

if (p) {
   p->MethodOfP();

Quote
}

Of course, the sample applies for constructors:

i.e. TComInterface<IMyInterface, &IID_IMyInterface> p(Server->SomeProperty);

Hope that helps.

Regards,

Bruneau.

Quote
Simon Gibbs wrote in message <7job79$85...@forums.borland.com>...
>Hi

>Is there an equivalent of _com_ptr_t (MSVC) in BCB4??

>I am retrieving an interface from a TVariant, and I currently have to get
>the IDispatch and do a Query Interface on it. IS there a quicker way??

>Simon

Other Threads