Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This class provides a template used by the default class factory code.

Create one CFactoryTemplateobject in an array for every object class so that the default class factory code can create new instances.

This class holds the name of the object, the object's class identifier (CLSID), and a pointer to the creation function for the corresponding object.

Initialize one of these in an array called g_Templates for each CLSID the application's DLL supports.

The creation function should take an LPUNKNOWN parameter and an HRESULTpointer and return an object derived from the CBaseObjectclass.

Set the HRESULTto a failed value if there is any error in construction.

An example declaration (from the Gargle sample filter) follows.

Copy Code
// list of class ids and creator functions for class factory
CFactoryTemplate g_Templates[2]= 
  { { L"Gargle filter"		 // CFactoryTemplate.m_name
  , &CLSID_Gargle			// CFactoryTemplate.m_ClsID 
  , CGargle::CreateInstance  // CFactoryTemplate.m_lpfnNew
  , NULL					 // CFactoryTemplate.m_lpfnInit
  , &sudGargle			 //
CFactoryTemplate.m_pAMovieSetup_Filter
								 }
  , { L"Gargle filter property page"
  , &CLSID_GargProp
  , CGargleProperties::CreateInstance
 }
 };
int g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]);

Note that the name of the object is strictly necessary only if you are using the DllRegisterServersetup routine to implement self-registering of your filter.

If you are not using this feature, you can set the first element of the g_Templates instance ( m_Name) to NULL or L"".

Protected Data Members

Member Description

m_ClsID

Pointer to the CLSID of the object class.

m_lpfnNew

Pointer to a function that creates an instance of the object class.

m_lpfnInit

Pointer to a function that initializes a new instance of the object class.

m_Name

Name of the filter; required when using filter self-registration services.

m_pAMovieSetup_Filter

Pointer to an AMOVIESETUP_FILTERstructure; required when using filter self-registration services.

Member Functions

Member function Description

CreateInstance

Calls the object-creation function for the class.

IsClassID

Determines whether a CLSID matches this class template.

Requirements

Windows Embedded CE Windows CE 2.12 and later
Windows Mobile Windows Mobile Version 5.0 and later
Note Microsoft DirectShow applications and DirectShow filters have different include file and Library requirements
For more information, see Setting Up the Build Environment