Microsoft DirectX 9.0

DLL Functions

A DLL must implement the following functions so that it can be registered, unregistered, and loaded into memory.

Of these, the first three are implemented by DirectShow. If your factory template provides an initialization function in the m_lpfnInit member variable, that function is called from inside the DLL entry-point function. For more information on when the system calls the DLL entry-point function, see DllMain in the Platform SDK.

You must implement DllRegisterServer and DllUnregisterServer, but DirectShow provides a function named AMovieDllRegisterServer2 that does the necessary work. Your component can simply wrap this function, as shown in the following example:

STDAPI DllRegisterServer()
    return AMovieDllRegisterServer2( TRUE );

STDAPI DllUnregisterServer()
    return AMovieDllRegisterServer2( FALSE );

However, within DllRegisterServer and DllUnregisterServer you can customize the registration process as needed. If your DLL contains a filter, you might need to do some additional work. For more information, see How to Register DirectShow Filters.

In your module-definition (.def) file, export all the DLL functions except for the entry-point function. The following is an example .def file:

    DllGetClassObject PRIVATE
    DllCanUnloadNow PRIVATE
    DllRegisterServer PRIVATE
    DllUnregisterServer PRIVATE

You can register the DLL using the Regsvr32.exe utility.