Anyone use com_ptr_t?

This is a discussion on Anyone use com_ptr_t? within the Game Programming forums, part of the General Programming Boards category; I was wondering whether any of you have used com_ptr_t and if you have, does it really do what it ...

  1. #1
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590

    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
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21