Microsoft DirectX 8.0

Programming Tips

This article contains information to help you develop Microsoft® DirectShow® applications effectively.

Global Objects

A global C++ object should not create DirectShow objects in its constructor method or release them in its destructor method. Doing so can cause the application to block indefinitely, for the following reason:

Threads cannot exit while inside a DLL's entry-point function. Kernel 32 holds a global process during the entry-point function, and the lock prevents the thread from exiting. Because some DirectShow objects own threads, they can block if released from inside a DLL entry-point function. If an application has a global C++ object, the C runtime DLL calls the object's destructor when the DLL is unloaded. If the destructor releases DirectShow objects, it can block as a result.

For similar reasons, a DLL should not create or release DirectShow objects in its entry point routine.

Filter Properties

If you create a DirectShow filter, application writers can be given access to your properties in a number of ways. You can provide property pages using the IProvidePropertyPages interface, which the application can then display. To allow the application to provide its own UI, you can also support the IPropertyBag interface which allows the application to query your filter and discover the properties. If you want to provide a specialized interface for your properties, you can also tailor an interface specifically to your filter and pin information.