IMFActivate::ActivateObject return error code “CoInitialize has not been called.”
I'm writing a simple multimedia application in Visual Studio 2013 and I need to enumerate camera devices connected to my computer and create a media source object to link to one of them. I use Media Foundation SDK and tried to run the guide here: https://msdn.microsoft.com/en-us/library/windows/desktop/dd940326(v=vs.85).aspx : #include <Mfapi.h> #include <mfidl.h> #include <mfobjects.h> #include <iostream> #pragma comment(lib, "Mfplat") #pragma comment(lib, "Mf") template <class T> void SafeRelease(T **ppT) { if (*ppT) { (*ppT)->Release(); *ppT = NULL; } } HRESULT CreateVideoDeviceSource