Search code examples
c++visual-c++comdirectshowtypelib

What DLLs do I #import when using DirectShow or other COM libraries in C++?


I am trying to use Compiler COM Support when calling DirectShow from C++. From an earlier post I know that I need to #import quartz.dll and qedit.dll. Doing that gives me smart pointer classes like IGraphBuilderPtr among others and I can see it supported by IntelliSense. I am now trying to use ICaptureGraphBuilder2 but it does not show up in the IntelliSense and attempting to #import devenum.dll, qcap.dll gives me a "C1803: Cannot open type library file". So, a couple of questions:

  1. What DLLs do I need to #import when using DirectShow interfaces?
  2. In general, given a COM library, how do I know which DLLs I can #import?

Solution

  • For C++ development you don't need to #import. Instead, you

    #include <dshow.h>
    #pragma comment(lib, "strmiids.lib")
    

    You have smart pointers with ATL, e.g. CComPtr<IFilterGraph2> (or QzCComPtr which only makes sense if you develop a filter as opposed to high level DirectShow consumer code).

    Hence,

    What DLLs do I need to #import when using DirectShow interfaces?

    None.

    In general, given a COM library, how do I know which DLLs I can #import?

    You need to know the DLL name or rather type library identifier. You get that from documentation or looking using SDK tools like COM/OLE Viewer, or via registry. I would recommend importing using type library identifier.

    From C++ code it only makes to import DirectShow DLLs if you need GUIDs, which are deprecated and excluded from SDK.