Or use a smart pointer built for COM such as CComPtr.
The COM stuff has reference counting but it's not automatic. You can use a custom deleter with a smart pointer to manage DX objects automatically.
No MFC, no ATL...
OMG, that could have been so useful when I was messing with COM.