Once you have implemented your class extension, registered the DLL, and added the DLL to the ESRI GeoObject Class Extensions component category, you will need a way of applying it to new or existing object classes.
When creating new object classes use one of the following methods to apply your class extension:
- Use the Schema wizard after modelling your class extension in UML.
- Use an ObjectClassDescription to automate the creation of new object classes in ArcCatalog (see the Timestamper example later in this section).
- Write code to call IFeatureWorkspace::CreateTable or IFeatureWorkspace::CreateFeatureClass, specifying your class extension's GUID for the EXTCLSID parameter.
The GUID of your class extension can be found in the registry under HKEY_CLASSES_ROOT\<Your ProgID>\CLSID. More simply, look for the GUID in the .reg script generated by the ESRI 'Compile and Register' Visual Basic Add-in.
For existing object classes, apply the class extension by calling IClassSchemaEdit::AlterClassExtensionCLSID as shown below.
' QI for the IClassSchemEdit interface
SetpClassSchemaEdit = pObjectClass
' set an exclusive lock on the class
SetpSchLock = pObjectClass pSchLock.ChangeSchemaLock (esriExclusiveSchemaLock)
' create the IUID object
NewUID pCUID.Value = "PipeValidation.PipeClassExtension"
' alter the class extension for the classpClassSchemaEdit.AlterClassExtensionCLSID pCUID,
' release the exclusive lockpSchLock.ChangeSchemaLock (esriSharedSchemaLock)
The IUID interface will automatically convert a ProgID to the corresponding GUID.
You can remove the class extension by passing `Nothing' as the first parameter to IClassSchemaEdit::AlterClassExtensionCLSID. However, if your class extension is faulty, you may not be able to open the object class and so would not be able to QI to IClassSchemaEdit. In this situation use IFeatureWorkspaceSchemaEdit to clear the class extension CLSID.
Note that an object class can only have one class extension. To combine two class extensions, you will need to merge their source code.