Thread: Anyone use com_ptr_t?

  1. #1
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607

    Anyone use com_ptr_t?

    I was wondering whether any of you have used com_ptr_t and if you have, does it really do what it says?

    I'm running into problems with COM interface pointers and I'm not sure everything is being released correctly.

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Yup, all the time. I use ATL's CComPtr though. Probably very similar in function I assume.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  3. #3
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Does it save COM pointer headaches and how do I go about using it correctly.

    The prototypes look quite confusing.

  4. #4
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    It's pretty straight forward, you would have something like this in your header:

    Code:
    CComPtr<IDirect3DDevice9> m_device;
    Oh, also include <atlbase.h> in your precompiled header or other appropriate location.

    Then the other use is identical as if it were a IDirect3DDevice9*. Just don't release it and you'll be fine. Do you have any other specific question? Try it out, I think you'll find it pretty easy to use.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

Popular pages Recent additions subscribe to a feed