See the question and my original answer on StackOverflow

It works fine.

The reason why you don't see much of this usage is because, the way it's designed, it looks like a really "private" method.

Plus it throws instead of returning an HRESULT. Personally, I always prefer returning an HRESULT instead of throwing (even if you carry a ComPtr around), because it's easier to handle.

Here is a (more convoluted, I admit) way of doing it that looks more "COM" (or more "Microsoft" if you will):

HRESULT GetSample(REFIID riid, void**ppv) // you can add other parameters (in front, and leave riid and ppv last)
  HRESULT hr = S_OK;
  CComPtr<IMFSample> pSample;

  hr = MFCreateSample(&pSample);
  if (hr != S_OK) return hr; // or if (FAILED(hr) ? depends if you handle S_FALSE an other non error cases

  // ...Create buffer, Add buffer, etc...

  return pSample->QueryInterface(riid, ppv);