Re: How to retrieve this pointer

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Yes I agree.
I did not design this application, but I must to make it functional now.
I dont like retrieving this pointer of com instance, it is temporary solution
because deadline knocks on our door.

Have you any tip how to do it ?

Peter


"Alexander Nickolov" wrote:

> So far, all very special cases I've seen that need this can be
> summed up with two words: bad design...
>
> --
> =====================================
> Alexander Nickolov
> Microsoft MVP [VC], MCSD
> email: agnickolov@xxxxxxxx
> MVP VC FAQ: http://www.mvps.org/vcfaq
> =====================================
>
> "Peter" <Peter@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:B96B0487-36E4-4DB6-9E1C-4481ADC79067@xxxxxxxxxxxxxxxx
> > My case is very special.
> > Can you give me some tips, link to articles ot other for trick with
> > retrieving this pointer ?
> >
> > Thanks !
> > Peter
> >
> > "Igor Tandetnik" wrote:
> >
> >> "Peter" <Peter@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> >> news:9EBEA11E-C44F-4BF9-BA85-2607DBBF438B@xxxxxxxxxxxxx
> >> > I have created comclass instance and I have pointer to i'ts IUnknown.
> >> > I need to retrieve this pointer for created instance.
> >> > How to do it ?
> >>
> >> In general, you don't. There are tricks to do it, but they are fragile
> >> and best avoided.
> >>
> >> If you create an instance of your coclass yourself, in the same module
> >> where it is implemented, you can use this instead of CoCreateInstance:
> >>
> >> CComObject<CMyClass>* pMyClass;
> >> CComObject<CMyClass>::CreateInstance(&pMyClass);
> >> // Here, pMyClass is a pointer to CComObject<CMyClass>
> >> // which is derived from CMyClass, so you can access all its
> >> // regular C++ methods.
> >> // Remember, the object is created with a refcount of 0 (zero).
> >>
> >> --
> >> With best wishes,
> >> Igor Tandetnik
> >>
> >> With sufficient thrust, pigs fly just fine. However, this is not
> >> necessarily a good idea. It is hard to be sure where they are going to
> >> land, and it could be dangerous sitting under them as they fly
> >> overhead. -- RFC 1925
> >>
> >>
> >>
>
>
>
.



Relevant Pages

  • Re: How to retrieve this pointer
    ... Microsoft MVP, MCSD ... > retrieving this pointer? ... >>> I have created comclass instance and I have pointer to i'ts IUnknown. ...
    (microsoft.public.vc.atl)
  • Re: Thinking assembly?
    ... much more than to learn the few assembler memonics. ... And that in anyway is flawed in design, ... even once to use VirtualAlloc and didnt know anything about it. ... header...then I can esaly calculate the pointer. ...
    (alt.lang.asm)
  • Re: Pointer question
    ... Even referencing a bad pointer can be undefined behaviour. ... could imagine another hardware-checked architecture where constructing ... relationship with regards to new hardware design. ...
    (comp.lang.c)
  • Re: Two questions about using shared_ptr
    ... should take a pointer or a const reference, ... [trys desperately not to use a bool or a pointer;)]. ... Is the function retrieving A "tagTool" as well as an index related ... struct tagTool tool = GetTool; ...
    (microsoft.public.vc.language)
  • Re: How to declare pointers to virtual base class methods ?
    ... Reconsider your design. ... Apart from compiler being unable to cast member ... > casting to the method pointer type of class A is necessary). ...
    (microsoft.public.vc.language)