共用方式為


Building DirectShow Filters

 
Microsoft DirectShow 9.0

Building DirectShow Filters

The DirectShow base classes are recommended for implementing DirectShow filters. To build with the base classes, perform the following steps, in addition to the steps listed in Setting Up the Build Environment:

  • Build the base class library, located in the directory Samples\Multimedia\DirectShow\BaseClasses, under the SDK root directory. There are two versions of the library: a retail version (Strmbase.lib) and a debug version (Strmbasd.lib).

  • Include the header file Streams.h.

  • Use the __stdcall calling convention.

  • Use the multithreaded C run-time library (debug or retail, as appropriate).

  • Include a definition (.def) file that exports the DLL functions. The following is an example of a definition file. It assumes that the output file is named MyFilter.dll.

    LIBRARY MYFILTER.DLL
    EXPORTS
    DllMain             PRIVATE
    DllGetClassObject   PRIVATE
    DllCanUnloadNow     PRIVATE
    DllRegisterServer   PRIVATE
    DllUnregisterServer PRIVATE
    

  • Link to the following lib files.

    Debug Build Strmbasd.lib, Msvcrtd.lib, Winmm.lib
    Retail Build Strmbase.lib, Msvcrt.lib, Winmm.lib
  • Choose the "ignore default libraries" option in the linker settings.

  • Declare the DLL entry point in your source code, as follows:

    extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE, ULONG, LPVOID);
    BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
    {
    return DllEntryPoint((HINSTANCE)(hModule), dwReason, lpReserved);
    }
    

Previous Versions

For versions of the base class library before DirectShow 9.0, you must also do the following:

  • For debug builds, define the preprocessor flag DEBUG.

This step is not required for the version of the base class library that is available in DirectShow 9.0 and later.

See Also