Controlling Filter Graphs Using C

[The feature associated with this page, DirectShow, is a legacy feature. It has been superseded by MediaPlayer, IMFMediaEngine, and Audio/Video Capture in Media Foundation. Those features have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use MediaPlayer, IMFMediaEngine and Audio/Video Capture in Media Foundation instead of DirectShow, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

If you are writing a DirectShow application in C (rather than C++), you must use a vtable pointer to call methods. The following example illustrates how to call the IUnknown::QueryInterface method from an application written in C:

pGraph->lpVtbl->QueryInterface(pGraph, &IID_IMediaEvent, (void **)&pEvent);

The following shows the equivalent call in C++:

pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);

In C, COM interfaces are defined as structures. The lpVtbl member is a pointer to a table of interface methods (the vtable). All methods take an additional parameter, which is a pointer to the interface.

Appendixes