Index Topic Contents | |||
Previous Topic: Recompress an AVI File Next Topic: Enumerate and Access Hardware Devices in DirectShow Applications |
Register DirectShow Objects
This section describes the steps you must take to make your Microsoft® DirectShow objects self-registering. It describes the relationships between the registry entry points called by COM, the globally-defined CFactoryTemplate array elements, and the AMOVIESETUP_MEDIATYPE, AMOVIESETUP_PIN, and AMOVIESETUP_FILTER structures.
To enable objects in a dynamic-link library (DLL) to register themselves, two COM-defined entry points must be provided in the DLL and exported:
With these entry points in your DLL, you can use the Regsvr32.exe tool to register and unregister your DLL or setup tools, or applications can register the filter programmatically.
Implementing Self-Registration
To implement a self-registering filter, carry out the following steps.
- Add DllRegisterServer and DllUnregisterServer to the export list in your filter's DEF file.
- Provide implementations for these functions, which call the DirectShow AMovieDllRegisterServer2 function with parameters of TRUE and FALSE, respectively. For example:
STDAPI DllRegisterServer() { return AMovieDllRegisterServer2(TRUE); } HRESULT DllUnregisterServer() { return AMovieDllRegisterServer2(FALSE); }You can add code to these functions to set up custom registry entries.
- Define the setup data structures for each filter based on the AMOVIESETUP_MEDIATYPE, AMOVIESETUP_PIN, and AMOVIESETUP_FILTER structures.
For example, here are the structures for the Ball.ax sample filter:
// Setup data const AMOVIESETUP_MEDIATYPE sudOpPinTypes = { &MEDIATYPE_Video , &MEDIASUBTYPE_NULL }; const AMOVIESETUP_PIN sudOpPin = { L"Output" , FALSE , TRUE , FALSE , FALSE , &CLSID_NULL , NULL , 1 , &sudOpPinTypes }; const AMOVIESETUP_FILTER sudBallax = { &CLSID_BouncingBall , L"Bouncing Ball" , MERIT_UNLIKELY , 1 , &sudOpPin };- In the CFactoryTemplate g_Templates array that instantiates your class, ensure that the first parameter has the name of the filter, (for example, "Bouncing Ball") and that the last parameter has the address of the AMOVIESETUP_FILTER structure you defined.
CFactoryTemplate gTemplates[]={ L"Bouncing Ball", // Name of the filter &CLSID_BouncingBall, // CLSID of the filter CBouncingBall::CreateInstance, // Static function to be called by class factory NULL, // &sudBallax} // Address of the AMOVIESETUP_FILTER structure };- Tag the DLL file as self-registering by adding the string "OLESelfRegistering" to its resource (defining AMOVIE_SELF_REGISTER in your resource file does this automatically if you are using Activex.rcv and Activex.ver). This string enables applications to determine whether the object is self-registering without loading the DLL.
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.