locked
ATL::CComPtr

    Question

  • For portability reasons I'd like to be able to use the ATL CComPtr smart pointer to handle DirectX interfaces in a Metro app. Is there any reason why ATL::CComPtr couldn't be used in place of WRL::ComPtr?

    Saturday, June 30, 2012 5:06 PM

Answers

  • We do this for the DirectXTK project. Take a look at 'PlatformHelpers.h'
    • Marked as answer by RobertHF Tuesday, July 3, 2012 10:21 AM
    Monday, July 2, 2012 8:21 PM

All replies

  • Hello,

    As far as I know, most of function in ALT::CComPtr can be find alternate in WRL::ComPtr.

    Do you have any farther request function in ALT::CComPtr?
     
    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Monday, July 2, 2012 8:15 AM
    Moderator
  • I was asking in the context of portability between C++/CX and C++/CLI (for use in a desktop application). I thought that if I stuck to ATL::CComPtr, that would give portability in dealing with DirectX interfaces. However, do I also have the option to do the reverse and use WRL::ComPtr in C++/CLI?

    Robert

    Monday, July 2, 2012 1:57 PM
  • Put your portable code in a static LIB project without WinRT/CX. So you can still use ATL.

    Then EXE pass the raw pointer to LIB.  An ID3D11Device pointer is mostly enough , you can get everything from it.



    • Edited by Raptor K Monday, July 2, 2012 3:24 PM
    Monday, July 2, 2012 3:08 PM
  • We do this for the DirectXTK project. Take a look at 'PlatformHelpers.h'
    • Marked as answer by RobertHF Tuesday, July 3, 2012 10:21 AM
    Monday, July 2, 2012 8:21 PM
  • Thanks,

    From your code, it looks like WRL::Comptr can be used in both metro and desktop applications.

    Robert

    Tuesday, July 3, 2012 10:25 AM
  • Yes, although if you want to support a platform prior to Windows 8, you have to use ATL's CComPtr.
    Tuesday, July 3, 2012 11:02 PM