Extending ArcObjects  

Managing Class Extensions

This topic is relevant for the following:
Product(s): ArcGIS Desktop: All
Version(s): 9.0, 9.1, 9.2, 9.3
Language(s): VB6, VC++
Experience level(s): Intermediate to advanced

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:

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.

[Visual Basic 6]
' QI for the IClassSchemEdit interface
Dim pClassSchemaEdit As IClassSchemaEdit
Set pClassSchemaEdit = pObjectClass
' set an exclusive lock on the class
Dim pSchLock As ISchemaLock
Set pSchLock = pObjectClass
pSchLock.ChangeSchemaLock (esriExclusiveSchemaLock)
' create the IUID object
Set pCUID = New UID
pCUID.Value = "PipeValidation.PipeClassExtension"
' alter the class extension for the class 
pClassSchemaEdit.AlterClassExtensionCLSID pCUID, Nothing
' release the exclusive lock 
pSchLock.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.

Back to top

See Also About Class Extensions, PipeValidation Class Extension, Timestamper Class Extension Example, Class Extensions and Relationship Classes, and Class Extensions for Annotation and Dimensions.